From 390ab6f851c3528ede29981eba010050cf16290c Mon Sep 17 00:00:00 2001 From: Syed Khaja Moinuddin Date: Sat, 8 Jun 2013 17:20:41 +0530 Subject: [PATCH] Fixed review comments in OptionMenu Signed-off-by: Syed Khaja Moinuddin Change-Id: I2d58e0a232f55761662b44e096fe66b3d7acc33f Signed-off-by: Syed Khaja Moinuddin --- inc/FUiCtrlOptionMenu.h | 48 ++--- src/ui/controls/FUiCtrlOptionMenu.cpp | 223 +++++++++---------- src/ui/controls/FUiCtrl_OptionMenu.cpp | 238 +++++++++++--------- src/ui/controls/FUiCtrl_OptionMenuImpl.cpp | 274 ++++++++++++------------ src/ui/controls/FUiCtrl_OptionMenuModel.cpp | 5 +- src/ui/controls/FUiCtrl_OptionMenuPresenter.cpp | 12 +- src/ui/inc/FUiCtrl_OptionMenu.h | 44 ++-- src/ui/inc/FUiCtrl_OptionMenuModel.h | 1 + 8 files changed, 437 insertions(+), 408 deletions(-) diff --git a/inc/FUiCtrlOptionMenu.h b/inc/FUiCtrlOptionMenu.h index 59518fa..0f9d769 100644 --- a/inc/FUiCtrlOptionMenu.h +++ b/inc/FUiCtrlOptionMenu.h @@ -259,13 +259,11 @@ public: * @param[in] pHighlightedBitmap The highlighted bitmap of the item * @param[in] actionId The action ID * @exception E_SUCCESS The method is successful. - * @exception E_MAX_EXCEEDED The total number of items has exceeded the maximum limit. * @exception E_SYSTEM This method has failed. * @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. @n - * %OptionMenu can have a maximum of @c 12 main items. */ - result AddItem (const Tizen::Graphics::Bitmap &normalBitmap, const Tizen::Graphics::Bitmap *pPressedBitmap, const Tizen::Graphics::Bitmap*pHighlightedBitmap, int actionId); + result AddItem (const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap, int actionId); /** * Appends new item to the end of %OptionMenu. @@ -279,10 +277,9 @@ public: * @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. - * @remarks %OptionMenu can have a maximum of @c 12 main items. + * @exception E_SYSTEM This method has failed. */ - result AddItem(const Base::String& text, int actionId, const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap = null, const Tizen::Graphics::Bitmap* pHighlightedBitmap = null); + 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 a specific item at the given index of %OptionMenu. @@ -294,9 +291,8 @@ public: * @param[in] text The item to 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_INVALID_ARG The specified @c index is invalid. * @exception E_SYSTEM The method has failed. - * @remarks %OptionMenu can have a maximum of @c 12 main items. */ result InsertItemAt(int mainIndex, const Tizen::Base::String& text, int actionId); @@ -312,13 +308,11 @@ public: * @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 total 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 @c 12. + * @exception E_INVALID_ARG The specified @c index is invalid. * @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. @n - * %OptionMenu can have a maximum of @c 12 main items. */ - result InsertItemAt (int mainIndex, const Tizen::Graphics::Bitmap &normalBitmap, const Tizen::Graphics::Bitmap *pPressedBitmap, const Tizen::Graphics::Bitmap*pHighlightedBitmap, int actionId); + result InsertItemAt (int mainIndex, const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap, int actionId); /** * Inserts a specific item at the given index of %OptionMenu. @@ -333,12 +327,10 @@ public: * @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_OUT_OF_RANGE The specified @c index is less than @c 0 or greater than @c 12. + * @exception E_INVALID_ARG The specified @c index is invalid. * @exception E_SYSTEM The method has failed. - * @remarks %OptionMenu can have a maximum of @c 12 main items. */ - result InsertItemAt (int mainIndex, const Tizen::Base::String &text, int actionId, const Tizen::Graphics::Bitmap &normalBitmap, const Tizen::Graphics::Bitmap*pPressedBitmap=null, const Tizen::Graphics::Bitmap *pHighlightedBitmap=null); + result InsertItemAt (int mainIndex, 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 a specific item at the given index of %OptionMenu. @@ -350,7 +342,7 @@ public: * @param[in] text The string of the item to 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_INVALID_ARG The specified @c index is invalid. * @exception E_SYSTEM The method has failed. */ result SetItemAt(int mainIndex, const Tizen::Base::String& text, int actionId); @@ -367,11 +359,11 @@ public: * @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_OUT_OF_RANGE The specified @c index is less than @c 0 or greater than @c 12. + * @exception E_INVALID_ARG The specified @c index is invalid. * @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. @n */ - result SetItemAt (int mainIndex, const Tizen::Graphics::Bitmap &normalBitmap, const Tizen::Graphics::Bitmap *pPressedBitmap, const Tizen::Graphics::Bitmap*pHighlightedBitmap, int actionId); + result SetItemAt (int mainIndex, const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap, int actionId); /** * Sets a specific item at the given index of %OptionMenu. @@ -386,9 +378,9 @@ public: * @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 is less than @c 0 or greater than @c 12. + * @exception E_INVALID_ARG The specified @c index is invalid. */ - result SetItemAt (int mainIndex, const Tizen::Base::String &text, int actionId, const Tizen::Graphics::Bitmap &normalBitmap, const Tizen::Graphics::Bitmap*pPressedBitmap=null, const Tizen::Graphics::Bitmap *pHighlightedBitmap=null); + result SetItemAt (int mainIndex, 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 of the specified index from %OptionMenu. @@ -398,7 +390,7 @@ public: * @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_INVALID_ARG The specified @c index is invalid. * @exception E_SYSTEM This method has failed. */ result RemoveItemAt(int mainIndex); @@ -449,7 +441,7 @@ public: * @param[in] text The string of item to append * @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_INVALID_ARG The specified @c index is invalid. * @exception E_SYSTEM This method has failed. * @remarks %OptionMenu can have a maximum of @c 32 sub-items. */ @@ -466,7 +458,7 @@ public: * @param[in] text The string of the item to 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_INVALID_ARG The specified @c index is invalid. * @exception E_SYSTEM This method has failed. * @remarks %OptionMenu can have a maximum of @c 32 sub-items. */ @@ -483,7 +475,7 @@ public: * @param[in] text The string of the item to 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_INVALID_ARG The specified @c index is invalid. * @exception E_SYSTEM This method has failed. */ result SetSubItemAt(int mainIndex, int subIndex, const Tizen::Base::String& text, int actionId); @@ -497,7 +489,7 @@ public: * @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_INVALID_ARG The specified @c index is invalid. * @exception E_SYSTEM This method has failed. */ result RemoveSubItemAt(int mainIndex, int subIndex); @@ -597,7 +589,7 @@ public: * @exception E_INVALID_STATE This instance is in an invalid state. * @see GetColor() */ - result SetColor(const Tizen::Graphics::Color &color); + result SetColor(const Tizen::Graphics::Color& color); /** * Gets the color of %OptionMenu. @@ -620,7 +612,7 @@ public: * @exception E_SUCCESS The method is successful. * @exception E_OUT_OF_RANGE The specified @c parameter is out of possible range. * @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 5. + * the maximum number of the visible menu items is @c 7 in potrait and @c 5 in Landscape. */ result SetMaxVisibleItemsCount(int maxItemsCount); diff --git a/src/ui/controls/FUiCtrlOptionMenu.cpp b/src/ui/controls/FUiCtrlOptionMenu.cpp index 2a96c39..a912a1d 100644 --- a/src/ui/controls/FUiCtrlOptionMenu.cpp +++ b/src/ui/controls/FUiCtrlOptionMenu.cpp @@ -26,6 +26,7 @@ #include "FUiCtrl_OptionMenuImpl.h" using namespace Tizen::Base; +using namespace Tizen::Graphics; namespace Tizen { namespace Ui { namespace Controls { @@ -43,7 +44,7 @@ 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."); + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); // Create _OptionMenuImpl _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::CreateOptionMenuImplN(*this); @@ -81,35 +82,35 @@ OptionMenu::RemoveActionEventListener(IActionEventListener& listener) } result -OptionMenu::AddItem(const Tizen::Base::String& text, int actionId) +OptionMenu::AddItem(const String& text, int actionId) { - ClearLastResult(); + ClearLastResult(); - _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); - SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); + _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); + SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); - result r = pOptionMenuImpl->AddItem(text, actionId, null, null, null); - SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + result r = pOptionMenuImpl->AddItem(text, actionId, null, null, null); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); - return r; + return r; } result -OptionMenu::AddItem (const Tizen::Graphics::Bitmap &normalBitmap, const Tizen::Graphics::Bitmap *pPressedBitmap, const Tizen::Graphics::Bitmap*pHighlightedBitmap, int actionId) +OptionMenu::AddItem(const Bitmap& normalBitmap, const Bitmap* pPressedBitmap, const Bitmap* pHighlightedBitmap, int actionId) { - ClearLastResult(); + ClearLastResult(); - _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); - SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); + _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); + SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); - result r = pOptionMenuImpl->AddItem(Tizen::Base::String(""), actionId, &normalBitmap, pPressedBitmap, pHighlightedBitmap); - SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + result r = pOptionMenuImpl->AddItem(String(""), actionId, &normalBitmap, pPressedBitmap, pHighlightedBitmap); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); - return r; + return r; } result -OptionMenu::AddItem(const Base::String& text, int actionId, const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap) +OptionMenu::AddItem(const String& text, int actionId, const Bitmap& normalBitmap, const Bitmap* pPressedBitmap, const Bitmap* pHighlightedBitmap) { ClearLastResult(); @@ -137,31 +138,31 @@ OptionMenu::InsertItemAt(int mainIndex, const String& text, int actionId) } result -OptionMenu::InsertItemAt (int mainIndex, const Tizen::Graphics::Bitmap &normalBitmap, const Tizen::Graphics::Bitmap *pPressedBitmap, const Tizen::Graphics::Bitmap*pHighlightedBitmap, int actionId) +OptionMenu::InsertItemAt(int mainIndex, const Bitmap& normalBitmap, const Bitmap* pPressedBitmap, const Bitmap* pHighlightedBitmap, int actionId) { - ClearLastResult(); + ClearLastResult(); - _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); - SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); + _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); + SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); - result r = pOptionMenuImpl->InsertItemAt(mainIndex, Tizen::Base::String(""), actionId, &normalBitmap, pPressedBitmap, pHighlightedBitmap); - SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + result r = pOptionMenuImpl->InsertItemAt(mainIndex, String(""), actionId, &normalBitmap, pPressedBitmap, pHighlightedBitmap); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); - return r; + return r; } result -OptionMenu::InsertItemAt (int mainIndex, const Tizen::Base::String &text, int actionId, const Tizen::Graphics::Bitmap &normalBitmap, const Tizen::Graphics::Bitmap*pPressedBitmap, const Tizen::Graphics::Bitmap *pHighlightedBitmap) +OptionMenu::InsertItemAt(int mainIndex, const String& text, int actionId, const Bitmap& normalBitmap, const Bitmap* pPressedBitmap, const Bitmap* pHighlightedBitmap) { - ClearLastResult(); + ClearLastResult(); - _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); - SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); + _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); + SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); - result r = pOptionMenuImpl->InsertItemAt(mainIndex, text, actionId, &normalBitmap, pPressedBitmap, pHighlightedBitmap); - SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + result r = pOptionMenuImpl->InsertItemAt(mainIndex, text, actionId, &normalBitmap, pPressedBitmap, pHighlightedBitmap); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); - return r; + return r; } result @@ -179,31 +180,31 @@ OptionMenu::SetItemAt(int mainIndex, const String& text, int actionId) } result -OptionMenu::SetItemAt (int mainIndex, const Tizen::Graphics::Bitmap &normalBitmap, const Tizen::Graphics::Bitmap *pPressedBitmap, const Tizen::Graphics::Bitmap*pHighlightedBitmap, int actionId) +OptionMenu::SetItemAt(int mainIndex, const Bitmap& normalBitmap, const Bitmap* pPressedBitmap, const Bitmap* pHighlightedBitmap, int actionId) { - ClearLastResult(); + ClearLastResult(); - _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); - SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); + _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); + SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); - result r = pOptionMenuImpl->SetItemAt(mainIndex, Tizen::Base::String(""), actionId, &normalBitmap, pPressedBitmap, pHighlightedBitmap); - SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + result r = pOptionMenuImpl->SetItemAt(mainIndex, String(""), actionId, &normalBitmap, pPressedBitmap, pHighlightedBitmap); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); - return r; + return r; } result -OptionMenu::SetItemAt (int mainIndex, const Tizen::Base::String &text, int actionId, const Tizen::Graphics::Bitmap &normalBitmap, const Tizen::Graphics::Bitmap*pPressedBitmap, const Tizen::Graphics::Bitmap *pHighlightedBitmap) +OptionMenu::SetItemAt(int mainIndex, const String &text, int actionId, const Bitmap& normalBitmap, const Bitmap* pPressedBitmap, const Bitmap* pHighlightedBitmap) { - ClearLastResult(); + ClearLastResult(); - _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); - SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); + _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); + SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); - result r = pOptionMenuImpl->SetItemAt(mainIndex, text, actionId, &normalBitmap, pPressedBitmap, pHighlightedBitmap); - SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + result r = pOptionMenuImpl->SetItemAt(mainIndex, text, actionId, &normalBitmap, pPressedBitmap, pHighlightedBitmap); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); - return r; + return r; } result @@ -221,18 +222,18 @@ OptionMenu::RemoveItemAt(int mainIndex) } void -OptionMenu::RemoveAllItems (void) +OptionMenu::RemoveAllItems(void) { - ClearLastResult(); + ClearLastResult(); - _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); - SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); + _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); + SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); - pOptionMenuImpl->RemoveAllItems(); - result r = GetLastResult(); - SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + pOptionMenuImpl->RemoveAllItems(); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); - return; + return; } int @@ -288,7 +289,7 @@ OptionMenu::AddSubItem(int mainIndex, const String& text, int actionId) _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); - result r = pOptionMenuImpl->AddSubItem(mainIndex, text, actionId); + result r = pOptionMenuImpl->AddSubItem(mainIndex, text, actionId); SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); return r; @@ -382,119 +383,119 @@ OptionMenu::GetSubItemActionIdAt(int mainIndex, int subIndex) const } result -OptionMenu::SetItemTextColor(OptionMenuItemStatus status, const Tizen::Graphics::Color& color) +OptionMenu::SetItemTextColor(OptionMenuItemStatus status, const Color& color) { - ClearLastResult(); + ClearLastResult(); - _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); - SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); + _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); + SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); - result r = pOptionMenuImpl->SetItemTextColor(status, color); - SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + result r = pOptionMenuImpl->SetItemTextColor(status, color); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); - return r; + return r; } -Tizen::Graphics::Color +Color OptionMenu::GetItemTextColor(OptionMenuItemStatus status) const { - ClearLastResult(); + ClearLastResult(); - const _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); - SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); + const _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); + SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); - Tizen::Graphics::Color color = pOptionMenuImpl->GetItemTextColor(status); - result r = GetLastResult(); - SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), Tizen::Graphics::Color(0, 0, 0, 0), r, "[%s] Propagating.", GetErrorMessage(r)); + Color color = pOptionMenuImpl->GetItemTextColor(status); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), Color(0, 0, 0, 0), r, "[%s] Propagating.", GetErrorMessage(r)); - return color; + return color; } result -OptionMenu::SetItemColor(OptionMenuItemStatus status, const Tizen::Graphics::Color& color) +OptionMenu::SetItemColor(OptionMenuItemStatus status, const Color& color) { - ClearLastResult(); + ClearLastResult(); - _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); - SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); + _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); + SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); - result r = pOptionMenuImpl->SetItemColor(status, color); - SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + result r = pOptionMenuImpl->SetItemColor(status, color); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); - return r; + return r; } -Tizen::Graphics::Color +Color OptionMenu::GetItemColor(OptionMenuItemStatus status) const { - ClearLastResult(); + ClearLastResult(); - const _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); - SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); + const _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); + SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); - Tizen::Graphics::Color color = pOptionMenuImpl->GetItemColor(status); - result r = GetLastResult(); - SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), Tizen::Graphics::Color(0, 0, 0, 0), r, "[%s] Propagating.", GetErrorMessage(r)); + Color color = pOptionMenuImpl->GetItemColor(status); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), Color(0, 0, 0, 0), r, "[%s] Propagating.", GetErrorMessage(r)); - return color; + return color; } result -OptionMenu::SetColor(const Tizen::Graphics::Color& color) +OptionMenu::SetColor(const Color& color) { - ClearLastResult(); + ClearLastResult(); - _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); - SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); + _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); + SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); - result r = pOptionMenuImpl->SetColor(color); - SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + result r = pOptionMenuImpl->SetColor(color); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); - return r; + return r; } -Tizen::Graphics::Color +Color OptionMenu::GetColor(void) const { - ClearLastResult(); + ClearLastResult(); - const _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); - SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); + const _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); + SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); - Tizen::Graphics::Color color = pOptionMenuImpl->GetColor(); - result r = GetLastResult(); - SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), Tizen::Graphics::Color(0, 0, 0, 0), r, "[%s] Propagating.", GetErrorMessage(r)); + Color color = pOptionMenuImpl->GetColor(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), Color(0, 0, 0, 0), r, "[%s] Propagating.", GetErrorMessage(r)); - return color; + return color; } result OptionMenu::SetMaxVisibleItemsCount(int maxItemsCount) { - ClearLastResult(); + ClearLastResult(); - _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); - SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); + _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); + SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); - result r = pOptionMenuImpl->SetMaxVisibleItemsCount(maxItemsCount); - SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + result r = pOptionMenuImpl->SetMaxVisibleItemsCount(maxItemsCount); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); - return r; + return r; } int OptionMenu::GetMaxVisibleItemsCount(void) const { - ClearLastResult(); + ClearLastResult(); - const _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); - SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); + const _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); + SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); - int count = pOptionMenuImpl->GetMaxVisibleItemsCount(); - result r = GetLastResult(); - SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), -1, r, "[%s] Propagating.", GetErrorMessage(r)); + int count = pOptionMenuImpl->GetMaxVisibleItemsCount(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), -1, r, "[%s] Propagating.", GetErrorMessage(r)); - return count; + return count; } }}} //Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_OptionMenu.cpp b/src/ui/controls/FUiCtrl_OptionMenu.cpp index af2a29e..6af3880 100644 --- a/src/ui/controls/FUiCtrl_OptionMenu.cpp +++ b/src/ui/controls/FUiCtrl_OptionMenu.cpp @@ -21,8 +21,9 @@ #include #include -#include #include + +#include #include "FUi_ControlImplManager.h" #include "FUi_ResourceManager.h" #include "FUiAnim_VisualElement.h" @@ -39,9 +40,10 @@ #include "FUi_TouchManager.h" using namespace Tizen::Graphics; +using namespace Tizen::Base; using namespace Tizen::Media; using namespace Tizen::Ui::Animations; -using namespace Tizen::Base::Runtime; +using namespace Runtime; namespace { static const float TOUCH_PRESS_THRESHOLD_INSENSITIVE = 0.16f; @@ -58,6 +60,7 @@ _OptionMenu::_OptionMenu(void) , __showItemMaxCount(0) , __isAttachedToMainTree(false) , __ownerInputEnableState(false) + , __isInOpenedState(false) , __windowRect(FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f)) , __bodyRect(FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f)) , __itemRect(FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f)) @@ -141,7 +144,7 @@ _OptionMenu::CreateOptionMenuN(void) r = pOptionMenu->CreateRootVisualElement(); SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - pOptionMenu->SetFocusable(true); + pOptionMenu->SetFocusable(true); r = pOptionMenu->Initialize(); SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to Initialize.", GetErrorMessage(r)); @@ -152,8 +155,8 @@ _OptionMenu::CreateOptionMenuN(void) pOptionMenu->AcquireHandle(); pOptionMenu->SetTouchPressThreshold(TOUCH_PRESS_THRESHOLD_INSENSITIVE); - pOptionMenu->SetMovable(false); - pOptionMenu->SetResizable(false); + pOptionMenu->SetMovable(false); + pOptionMenu->SetResizable(false); if (pOptionMenu->GetAccessibilityContainer() != null) { @@ -175,7 +178,7 @@ _OptionMenu::CreateOptionMenuN(void) pOptionMenu->AttachChild(*(pOptionMenu->__pScrollPanel)); } - GET_SHAPE_CONFIG(OPTIONMENU::MAX_OPTIONMENU_SHOW_ITEM, pOptionMenu->GetOrientation(), pOptionMenu->__showItemMaxCount); + GET_SHAPE_CONFIG(OPTIONMENU::MAX_OPTIONMENU_SHOW_ITEM, pOptionMenu->GetOrientation(), pOptionMenu->__showItemMaxCount); return pOptionMenu; @@ -217,22 +220,36 @@ _OptionMenu::GetScrollPanel(void) // return __pOptionMenuPresenter->OnKeyPressed(source, keyInfo); //} -//bool -//_OptionMenu::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo) -//{ -// AppLog("vipul : OnKeyReleased"); -// _KeyCode keyCode = keyInfo.GetKeyCode(); +bool +_OptionMenu::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo) +{ + _KeyCode keyCode = keyInfo.GetKeyCode(); -// if (keyCode == _KEY_UP || keyCode == _KEY_DOWN || keyCode == _KEY_ENTER) -// { -// return true; -// } + if (keyCode == _KEY_ESC || keyCode == _KEY_CLEAR) + { + SetVisibleState(false); + return true; + } -// return false; -//} + if (keyCode == _KEY_CONTEXT_MENU) + { + if (__isInOpenedState) + { + SetVisibleState(false); + } + else + { + __isInOpenedState = true; + } + + return true; + } + + return false; +} //bool -//_OptionMenu::OnFocusGained(const _Control &source) +//_OptionMenu::OnFocusGained(const _Control &source)__pOption //{ // AppLog("vipul : OnFocusGained"); // //__pScrollPanel->SetFocused(true); @@ -342,7 +359,7 @@ _OptionMenu::SetPresenter(const _OptionMenuPresenter& OptionMenuPresenter) } void -_OptionMenu::OnDraw() +_OptionMenu::OnDraw(void) { __pOptionMenuPresenter->Draw(); @@ -383,11 +400,9 @@ _OptionMenu::OnAttachedToMainTree(void) r = __pOptionMenuPresenter->CalculateWindowRect(); SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult())); - r = Open(); - - SetVisibleState(true); + //r = Open(); - SetTouchCapture(false, false); + //SetVisibleState(true); SetAllAccessibilityElement(); @@ -415,13 +430,14 @@ _OptionMenu::OnAttachedToMainTree(void) pVisualElement->SetImplicitAnimationEnabled(enable); - return _Window::OnAttachedToMainTree(); + return _Window::OnAttachedToMainTree();static const int DEFAULT_ITEM_COUNT = 32; + const int INVALID_INDEX = -1; + const int MAX_MAIN_ITEM_COUNT = 12; } result _OptionMenu::OnDetachingFromMainTree(void) { - ReleaseTouchCapture(); _Control* pOwner = GetOwner(); @@ -432,12 +448,26 @@ _OptionMenu::OnDetachingFromMainTree(void) __isAttachedToMainTree = false; - return _Window::OnDetachingFromMainTree(); + return _Window::OnDetachingFromMainTree(); +} + +void +_OptionMenu::OnActivated(void) +{ + SetTouchCapture(false, false); + return _Window::OnActivated(); +} + +void +_OptionMenu::OnDeactivated(void) +{ + __isInOpenedState = false; + return _Window::OnDeactivated(); } result -_OptionMenu::AddItem(const Base::String& text, int actionId, const Bitmap* pNormalBitmap, - const Bitmap* pPressedBitmap, const Bitmap* pHighlightedBitmap) +_OptionMenu::AddItem(const String& text, int actionId, const Bitmap* pNormalBitmap, + const Bitmap* pPressedBitmap, const Bitmap* pHighlightedBitmap) { result r = E_SUCCESS; @@ -455,17 +485,17 @@ _OptionMenu::AddItem(const Base::String& text, int actionId, const Bitmap* pNorm result _OptionMenu::InsertItemAt(int mainIndex, const String& text, int actionId, const Bitmap* pNormalBitmap, const Bitmap* pPressedBitmap, const Bitmap* pHighlightedBitmap) { - result r = E_SUCCESS; + result r = E_SUCCESS; - r = __pOptionMenuPresenter->InsertItem(mainIndex, text, actionId, pNormalBitmap, pPressedBitmap, pHighlightedBitmap); - SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to add a item."); + r = __pOptionMenuPresenter->InsertItem(mainIndex, text, actionId, pNormalBitmap, pPressedBitmap, pHighlightedBitmap); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to add a item."); - __actionId.InsertAt(actionId, mainIndex); + __actionId.InsertAt(actionId, mainIndex); - __pOptionMenuPresenter->CalculateShowItemCount(); - __pOptionMenuPresenter->CalculateWindowRect(); + __pOptionMenuPresenter->CalculateShowItemCount(); + __pOptionMenuPresenter->CalculateWindowRect(); - return r; + return r; } int @@ -477,16 +507,16 @@ _OptionMenu::GetItemIndexFromActionId(int actionId) const result _OptionMenu::SetItemAt(int mainIndex, const String& text, int actionId, const Bitmap* pNormalBitmap, const Bitmap* pPressedBitmap, const Bitmap* pHighlightedBitmap) { - result r = E_SUCCESS; + result r = E_SUCCESS; - r = __pOptionMenuPresenter->SetItem(mainIndex, text, actionId, pNormalBitmap, pPressedBitmap, pHighlightedBitmap); - SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to set a item."); + r = __pOptionMenuPresenter->SetItem(mainIndex, text, actionId, pNormalBitmap, pPressedBitmap, pHighlightedBitmap); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to set a item."); - __actionId.SetAt(actionId, mainIndex); + __actionId.SetAt(actionId, mainIndex); - __pOptionMenuPresenter->CalculateWindowRect(); + __pOptionMenuPresenter->CalculateWindowRect(); - return r; + return r; } result @@ -497,7 +527,7 @@ _OptionMenu::AddSubItem(int mainIndex, const String& text, int actionId) if (__pSubMenu != null && mainIndex == __subMenuIndex) { - __pSubMenu->AddItem(text, actionId, null, null, null); + __pSubMenu->AddItem(text, actionId, null, null, null); } return E_SUCCESS; } @@ -505,15 +535,15 @@ _OptionMenu::AddSubItem(int mainIndex, const String& text, int actionId) 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)); + 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); - } + if (__pSubMenu != null && mainIndex == __subMenuIndex) + { + __pSubMenu->InsertItem(subIndex, text, actionId, null, null, null); + } - return E_SUCCESS; + return E_SUCCESS; } result @@ -524,7 +554,7 @@ _OptionMenu::SetSubItemAt(int mainIndex, int subIndex, const String& text, int a if (__pSubMenu != null && mainIndex == __subMenuIndex) { - __pSubMenu->SetItem(subIndex, text, actionId, null, null, null); + __pSubMenu->SetItem(subIndex, text, actionId, null, null, null); } return E_SUCCESS; @@ -538,7 +568,7 @@ _OptionMenu::RemoveSubItemAt(int mainIndex, int subIndex) if (__pSubMenu != null && mainIndex == __subMenuIndex) { - __pSubMenu->RemoveItemAt(subIndex); + __pSubMenu->RemoveItemAt(subIndex); } return E_SUCCESS; @@ -568,50 +598,50 @@ _OptionMenu::ShowSubMenu(int mainIndex, _OptionMenuItem& item, FloatPoint touchP { if (__pSubMenu != null) { - DestroySubMenu(); + DestroySubMenu(); } float textSize = 0.0f; float itemHeight = 0.0f; -// Font* pFont = __pOptionMenuPresenter->GetFont(); + // Font* pFont = __pOptionMenuPresenter->GetFont(); GET_SHAPE_CONFIG(OPTIONMENU::TEXT_SIZE, GetOrientation(), textSize); GET_SHAPE_CONFIG(CONTEXTMENU::LIST_ITEM_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, itemHeight); -// FloatRectangle itemBounds = __pOptionMenuPresenter->GetItemBounds(mainIndex); + // FloatRectangle itemBounds = __pOptionMenuPresenter->GetItemBounds(mainIndex); _OptionMenuItem* pMainItem = __pOptionMenuPresenter->GetItemFromPosition(touchPosition).pOptionMenuItem; FloatRectangle itemBounds = pMainItem->GetBoundsF(); itemBounds.height = itemHeight; float scrollPosition = __pScrollPanel->GetScrollPosition(); FloatPoint anchorPosition(GetBoundsF().x + itemBounds.x + itemBounds.width, - GetBoundsF().y + itemBounds.y + itemBounds.height / 2.0f - scrollPosition); + GetBoundsF().y + itemBounds.y + itemBounds.height / 2.0f - scrollPosition); -// FloatPoint anchorPosition = touchPosition; + // FloatPoint anchorPosition = touchPosition; __pSubMenu = _ContextMenu::CreateContextMenuN(anchorPosition, CONTEXT_MENU_CORE_STYLE_LIST, CONTEXT_MENU_CORE_ALIGN_RIGHT); if (__pSubMenu == null) { - return GetLastResult(); + return GetLastResult(); } __pSubMenu->SetFocusable(true); 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); - } + _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(); @@ -621,17 +651,17 @@ _OptionMenu::ShowSubMenu(int mainIndex, _OptionMenuItem& item, FloatPoint touchP 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); - } + pSubItem = item.GetSubItem(subIndex); + if (pSubItem != null) + { + __pSubMenu->AddItem(pSubItem->GetText(), pSubItem->GetActionId(), null, null, null); + } } -// if (pFont != null) -// { -// __pSubMenu->SetFont(pFont->GetFaceName()); -// } + // if (pFont != null) + // { + // __pSubMenu->SetFont(pFont->GetFaceName()); + // } __pSubMenu->Open(); __subMenuIndex = mainIndex; @@ -650,7 +680,7 @@ _OptionMenu::DestroySubMenu(void) { if (__pSubMenu == null) { - return E_SYSTEM; + return E_SYSTEM; } __pSubMenu->Close(); @@ -662,8 +692,8 @@ _OptionMenu::DestroySubMenu(void) } result -_OptionMenu::InsertItem(int index, const Base::String& text, int actionId, const Bitmap* pNormalBitmap, - const Bitmap* pPressedBitmap, const Bitmap* pHighlightedBitmap) +_OptionMenu::InsertItem(int index, const String& text, int actionId, const Bitmap* pNormalBitmap, + const Bitmap* pPressedBitmap, const Bitmap* pHighlightedBitmap) { result r = E_SUCCESS; @@ -679,8 +709,8 @@ _OptionMenu::InsertItem(int index, const Base::String& text, int actionId, const } result -_OptionMenu::SetItem(int index, const Base::String& text, int actionId, const Bitmap* pNormalBitmap, - const Bitmap* pPressedBitmap, const Bitmap* pHighlightedBitmap) +_OptionMenu::SetItem(int index, const String& text, int actionId, const Bitmap* pNormalBitmap, + const Bitmap* pPressedBitmap, const Bitmap* pHighlightedBitmap) { result r = E_SUCCESS; @@ -716,7 +746,7 @@ _OptionMenu::RemoveAllItems(void) result r = E_SUCCESS; r = __pOptionMenuPresenter->DeleteItemAll(); - SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Failed to remove all items.", GetErrorMessage(r)); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Failed to remove all items.", GetErrorMessage(r)); __actionId.RemoveAll(); @@ -892,12 +922,12 @@ _OptionMenu::GetColor(void) const result _OptionMenu::SetMaxVisibleItemsCount(int maxItemsCount) { - SetPropertyMaxVisibleItemsCount(maxItemsCount); + SetPropertyMaxVisibleItemsCount(maxItemsCount); - __pOptionMenuPresenter->CalculateShowItemCount(); - __pOptionMenuPresenter->CalculateWindowRect(); + __pOptionMenuPresenter->CalculateShowItemCount(); + __pOptionMenuPresenter->CalculateWindowRect(); - return E_SUCCESS; + return E_SUCCESS; } result @@ -1080,7 +1110,7 @@ _OptionMenu::GetTextColor(enum OptionMenuCoreItemStatus status) const } result -_OptionMenu::AddActionEventListener(const Tizen::Ui::Controls::_IActionEventListener& listener) +_OptionMenu::AddActionEventListener(const _IActionEventListener& listener) { result r = E_SUCCESS; @@ -1088,10 +1118,10 @@ _OptionMenu::AddActionEventListener(const Tizen::Ui::Controls::_IActionEventList { __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.") + "[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.") + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to remove an action event listener."); } return r; @@ -1103,15 +1133,15 @@ CATCH: } result -_OptionMenu::RemoveActionEventListener(const Tizen::Ui::Controls::_IActionEventListener& listener) +_OptionMenu::RemoveActionEventListener(const _IActionEventListener& listener) { SysTryReturn(NID_UI_CTRL, __pActionEvent != null, E_INVALID_STATE, E_INVALID_STATE, - "[E_INVALID_STATE] The action event instance isn't constructed.") + "[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") + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to remove an action event listener"); return r; } @@ -1128,7 +1158,7 @@ _OptionMenu::FireActionEvent(int actionId) return r; } -Tizen::Ui::Controls::_ActionEvent* +_ActionEvent* _OptionMenu::GetActionEvent(void) const { return __pActionEvent; @@ -1163,7 +1193,7 @@ CATCH: } result -_OptionMenu::LoadColorReplacedBitmap(const Tizen::Graphics::Color& color) +_OptionMenu::LoadColorReplacedBitmap(const Color& color) { Bitmap* ptempNormalBitmap = null; @@ -1174,14 +1204,14 @@ _OptionMenu::LoadColorReplacedBitmap(const Tizen::Graphics::Color& color) __pBackgroundNormalBitmap = null; } - result r; + result r; 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; + delete ptempNormalBitmap; return r; @@ -1259,7 +1289,7 @@ _OptionMenu::OnActionPerformed(const _Control& source, int actionId) } void -_OptionMenu::OnFontChanged(Tizen::Graphics::Font* pFont) +_OptionMenu::OnFontChanged(Font* pFont) { return __pOptionMenuPresenter->OnFontChanged(pFont); } @@ -1273,11 +1303,11 @@ _OptionMenu::OnFontInfoRequested(unsigned long& style, float& size) void _OptionMenu::OnChangeLayout(_ControlOrientation orientation) { - AppLog("vipul : OnChangeLayout"); - GET_SHAPE_CONFIG(OPTIONMENU::MAX_OPTIONMENU_SHOW_ITEM, orientation, __showItemMaxCount); + AppLog("vipul : OnChangeLayout"); + GET_SHAPE_CONFIG(OPTIONMENU::MAX_OPTIONMENU_SHOW_ITEM, orientation, __showItemMaxCount); - __pOptionMenuPresenter->CalculateShowItemCount(); - __pOptionMenuPresenter->CalculateWindowRect(); + __pOptionMenuPresenter->CalculateShowItemCount(); + __pOptionMenuPresenter->CalculateWindowRect(); if (__isAttachedToMainTree == true) { diff --git a/src/ui/controls/FUiCtrl_OptionMenuImpl.cpp b/src/ui/controls/FUiCtrl_OptionMenuImpl.cpp index 7c4db23..5af4519 100644 --- a/src/ui/controls/FUiCtrl_OptionMenuImpl.cpp +++ b/src/ui/controls/FUiCtrl_OptionMenuImpl.cpp @@ -23,6 +23,7 @@ #include #include +#include "FUi_ResourceManager.h" #include "FUiCtrl_OptionMenuImpl.h" #include "FUiCtrl_PublicActionEvent.h" @@ -61,6 +62,10 @@ _OptionMenuImpl::CreateOptionMenuImplN(OptionMenu& control) result r = GetLastResult(); SysTryReturn(NID_UI_CTRL, (pCore != null), null, r, "[%s] Propagating.", GetErrorMessage(r)); + int itemMaxCount = 0; + GET_SHAPE_CONFIG(CONTEXTMENU::ITEM_MAX_COUNT, _CONTROL_ORIENTATION_PORTRAIT, itemMaxCount); + pCore->SetShowItemCount(itemMaxCount); + _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)); @@ -68,7 +73,7 @@ _OptionMenuImpl::CreateOptionMenuImplN(OptionMenu& control) pImpl->__pPublicActionEvent = _PublicActionEvent::CreateInstanceN(control); r = GetLastResult(); SysTryCatch(NID_UI_CTRL, (pImpl->__pPublicActionEvent != null), , r, - "[%s] Propagating.", GetErrorMessage(r)); + "[%s] Propagating.", GetErrorMessage(r)); r = pCore->AddActionEventListener(*pImpl); SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); @@ -107,7 +112,7 @@ _OptionMenuImpl::RemoveActionEventListener(IActionEventListener& listener) result _OptionMenuImpl::AddItem(const String& text, int actionId, const Bitmap* pNormalBitmap, - const Bitmap* pPressedBitmap, const Bitmap* pHighlightedBitmap) + const Bitmap* pPressedBitmap, const Bitmap* pHighlightedBitmap) { ClearLastResult(); @@ -115,45 +120,45 @@ _OptionMenuImpl::AddItem(const String& text, int actionId, const Bitmap* pNormal } result -_OptionMenuImpl::InsertItemAt (int mainIndex, const String& text, int actionId, const Bitmap* normalBitmap, - const Bitmap* pPressedBitmap, const Bitmap *pHighlightedBitmap) +_OptionMenuImpl::InsertItemAt(int mainIndex, const String& text, int actionId, const Bitmap* normalBitmap, + const Bitmap* pPressedBitmap, const Bitmap *pHighlightedBitmap) { - 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); + ClearLastResult(); + SysTryReturn(NID_UI_CTRL, (mainIndex >= 0), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] The specified main index (%d) is negative.", mainIndex); - return GetCore().InsertItemAt(mainIndex, text, actionId, normalBitmap, pPressedBitmap, pHighlightedBitmap); + return GetCore().InsertItemAt(mainIndex, text, actionId, normalBitmap, pPressedBitmap, pHighlightedBitmap); } result -_OptionMenuImpl::SetItemAt (int mainIndex, const String& text, int actionId, const Bitmap* normalBitmap, - const Bitmap* pPressedBitmap, const Bitmap *pHighlightedBitmap) +_OptionMenuImpl::SetItemAt(int mainIndex, const String& text, int actionId, const Bitmap* normalBitmap, + const Bitmap* pPressedBitmap, const Bitmap *pHighlightedBitmap) { - 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); + ClearLastResult(); + SysTryReturn(NID_UI_CTRL, (mainIndex >= 0), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] The specified main index (%d) is negative.", mainIndex); - return GetCore().SetItemAt(mainIndex, text, actionId, normalBitmap, pPressedBitmap, pHighlightedBitmap); + return GetCore().SetItemAt(mainIndex, text, actionId, normalBitmap, pPressedBitmap, pHighlightedBitmap); } 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); + SysTryReturn(NID_UI_CTRL, (mainIndex >= 0), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] The specified main index (%d) is negative.", mainIndex); return GetCore().RemoveItemAt(mainIndex); } void -_OptionMenuImpl::RemoveAllItems (void) +_OptionMenuImpl::RemoveAllItems(void) { - ClearLastResult(); + ClearLastResult(); - GetCore().RemoveAllItems(); + GetCore().RemoveAllItems(); - return; + return; } int @@ -176,8 +181,8 @@ 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); + SysTryReturn(NID_UI_CTRL, (mainIndex >= 0), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] The specified main index (%d) is negative.", mainIndex); return GetCore().GetItemActionIdAt(mainIndex); } @@ -186,8 +191,8 @@ 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); + SysTryReturn(NID_UI_CTRL, (mainIndex >= 0), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] The specified main index (%d) is negative.", mainIndex); return GetCore().AddSubItem(mainIndex, text, actionId); } @@ -196,10 +201,10 @@ 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); + SysTryReturn(NID_UI_CTRL, (mainIndex >= 0), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] The specified main index (%d) is negative.", mainIndex); + SysTryReturn(NID_UI_CTRL, (subIndex >= 0), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] The specified sub index (%d) is negative.", subIndex); return GetCore().InsertSubItemAt(mainIndex, subIndex, text, actionId); } @@ -208,10 +213,10 @@ 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); + SysTryReturn(NID_UI_CTRL, (mainIndex >= 0), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] The specified main index (%d) is negative.", mainIndex); + SysTryReturn(NID_UI_CTRL, (subIndex >= 0), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] The specified sub index (%d) is negative.", subIndex); return GetCore().SetSubItemAt(mainIndex, subIndex, text, actionId); } @@ -220,10 +225,10 @@ 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); + SysTryReturn(NID_UI_CTRL, (mainIndex >= 0), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] The specified main index (%d) is negative.", mainIndex); + SysTryReturn(NID_UI_CTRL, (subIndex >= 0), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] The specified sub index (%d) is negative.", subIndex); return GetCore().RemoveSubItemAt(mainIndex, subIndex); } @@ -232,8 +237,8 @@ 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); + SysTryReturn(NID_UI_CTRL, (mainIndex >= 0), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] The specified main index (%d) is negative.", mainIndex); return GetCore().GetSubItemCount(mainIndex); } @@ -243,179 +248,178 @@ _OptionMenuImpl::GetSubItemIndexFromActionId(int actionId) const { ClearLastResult(); - return GetCore().GetSubItemIndexFromActionId(actionId); + 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); + SysTryReturn(NID_UI_CTRL, (mainIndex >= 0), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] The specified main index (%d) is negative.", mainIndex); + SysTryReturn(NID_UI_CTRL, (subIndex >= 0), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] The specified sub index (%d) is negative.", subIndex); - return GetCore().GetSubItemActionIdAt(mainIndex, subIndex); + return GetCore().GetSubItemActionIdAt(mainIndex, subIndex); } result _OptionMenuImpl::SetItemTextColor(OptionMenuItemStatus status, const Color& color) { - ClearLastResult(); - - result r = E_SUCCESS; - - switch (status) - { - case OPTION_MENU_ITEM_STATUS_NORMAL: - r = GetCore().SetTextColor(OPTION_MENU_CORE_ITEM_STATUS_NORMAL, color); - break; - - case OPTION_MENU_ITEM_STATUS_PRESSED: - r = GetCore().SetTextColor(OPTION_MENU_CORE_ITEM_STATUS_PRESSED, color); - break; + ClearLastResult(); - case OPTION_MENU_ITEM_STATUS_HIGHLIGHTED: - r = GetCore().SetTextColor(OPTION_MENU_CORE_ITEM_STATUS_HIGHLIGHTED, color); - break; + result r = E_SUCCESS; - default: - SysLogException(NID_UI_CTRL, E_INVALID_ARG, "Invalid argument at OptionMenuItemStatus."); - r = E_INVALID_ARG; - break; - } + switch (status) + { + case OPTION_MENU_ITEM_STATUS_NORMAL: + r = GetCore().SetTextColor(OPTION_MENU_CORE_ITEM_STATUS_NORMAL, color); + break; + + case OPTION_MENU_ITEM_STATUS_PRESSED: + r = GetCore().SetTextColor(OPTION_MENU_CORE_ITEM_STATUS_PRESSED, color); + break; + + case OPTION_MENU_ITEM_STATUS_HIGHLIGHTED: + r = GetCore().SetTextColor(OPTION_MENU_CORE_ITEM_STATUS_HIGHLIGHTED, color); + break; + + default: + SysLogException(NID_UI_CTRL, E_INVALID_ARG, "Invalid argument at OptionMenuItemStatus."); + r = E_INVALID_ARG; + break; + } - return r; + return r; } Color _OptionMenuImpl::GetItemTextColor(OptionMenuItemStatus status) const { - ClearLastResult(); + ClearLastResult(); - Tizen::Graphics::Color color(0, 0, 0, 0); + Tizen::Graphics::Color color(0, 0, 0, 0); - switch (status) - { - case OPTION_MENU_ITEM_STATUS_NORMAL: - color = GetCore().GetTextColor(OPTION_MENU_CORE_ITEM_STATUS_NORMAL); - break; + switch (status) + { + case OPTION_MENU_ITEM_STATUS_NORMAL: + color = GetCore().GetTextColor(OPTION_MENU_CORE_ITEM_STATUS_NORMAL); + break; - case OPTION_MENU_ITEM_STATUS_PRESSED: - color = GetCore().GetTextColor(OPTION_MENU_CORE_ITEM_STATUS_PRESSED); - break; + case OPTION_MENU_ITEM_STATUS_PRESSED: + color = GetCore().GetTextColor(OPTION_MENU_CORE_ITEM_STATUS_PRESSED); + break; - case OPTION_MENU_ITEM_STATUS_HIGHLIGHTED: - color = GetCore().GetTextColor(OPTION_MENU_CORE_ITEM_STATUS_HIGHLIGHTED); - break; + case OPTION_MENU_ITEM_STATUS_HIGHLIGHTED: + color = GetCore().GetTextColor(OPTION_MENU_CORE_ITEM_STATUS_HIGHLIGHTED); + break; - default: - SysLogException(NID_UI_CTRL, E_SYSTEM, "Invalid argument at ContextMenuItemStatus."); - break; - } + default: + SysLogException(NID_UI_CTRL, E_SYSTEM, "Invalid argument at ContextMenuItemStatus."); + break; + } - return color; + return color; } result _OptionMenuImpl::SetItemColor(OptionMenuItemStatus status, const Color& color) { - ClearLastResult(); - - result r = E_SUCCESS; - - switch (status) - { - case OPTION_MENU_ITEM_STATUS_NORMAL: - r = GetCore().SetItemColor(OPTION_MENU_CORE_ITEM_STATUS_NORMAL, color); - break; - - case OPTION_MENU_ITEM_STATUS_PRESSED: - r = GetCore().SetItemColor(OPTION_MENU_CORE_ITEM_STATUS_PRESSED, color); - break; + ClearLastResult(); - case OPTION_MENU_ITEM_STATUS_HIGHLIGHTED: - r = GetCore().SetItemColor(OPTION_MENU_CORE_ITEM_STATUS_HIGHLIGHTED, color); - break; + result r = E_SUCCESS; - default: - SysLogException(NID_UI_CTRL, E_INVALID_ARG, "Invalid argument at OptionMenuItemStatus."); - r = E_INVALID_ARG; - break; - } + switch (status) + { + case OPTION_MENU_ITEM_STATUS_NORMAL: + r = GetCore().SetItemColor(OPTION_MENU_CORE_ITEM_STATUS_NORMAL, color); + break; + + case OPTION_MENU_ITEM_STATUS_PRESSED: + r = GetCore().SetItemColor(OPTION_MENU_CORE_ITEM_STATUS_PRESSED, color); + break; + + case OPTION_MENU_ITEM_STATUS_HIGHLIGHTED: + r = GetCore().SetItemColor(OPTION_MENU_CORE_ITEM_STATUS_HIGHLIGHTED, color); + break; + + default: + SysLogException(NID_UI_CTRL, E_INVALID_ARG, "Invalid argument at OptionMenuItemStatus."); + r = E_INVALID_ARG; + break; + } - return r; + return r; } Color _OptionMenuImpl::GetItemColor(OptionMenuItemStatus status) const { - ClearLastResult(); + ClearLastResult(); - Tizen::Graphics::Color color(0, 0, 0, 0); + Tizen::Graphics::Color color(0, 0, 0, 0); - switch (status) - { - case OPTION_MENU_ITEM_STATUS_NORMAL: - color = GetCore().GetItemColor(OPTION_MENU_CORE_ITEM_STATUS_NORMAL); - break; + switch (status) + { + case OPTION_MENU_ITEM_STATUS_NORMAL: + color = GetCore().GetItemColor(OPTION_MENU_CORE_ITEM_STATUS_NORMAL); + break; - case OPTION_MENU_ITEM_STATUS_PRESSED: - color = GetCore().GetItemColor(OPTION_MENU_CORE_ITEM_STATUS_PRESSED); - break; + case OPTION_MENU_ITEM_STATUS_PRESSED: + color = GetCore().GetItemColor(OPTION_MENU_CORE_ITEM_STATUS_PRESSED); + break; - case OPTION_MENU_ITEM_STATUS_HIGHLIGHTED: - color = GetCore().GetItemColor(OPTION_MENU_CORE_ITEM_STATUS_HIGHLIGHTED); - break; + case OPTION_MENU_ITEM_STATUS_HIGHLIGHTED: + color = GetCore().GetItemColor(OPTION_MENU_CORE_ITEM_STATUS_HIGHLIGHTED); + break; - default: - SysLogException(NID_UI_CTRL, E_SYSTEM, "Invalid argument at ContextMenuItemStatus."); - break; - } + default: + SysLogException(NID_UI_CTRL, E_SYSTEM, "Invalid argument at ContextMenuItemStatus."); + break; + } - return color; + return color; } result _OptionMenuImpl::SetColor(const Color& color) { - ClearLastResult(); + ClearLastResult(); - return GetCore().SetColor(color); + return GetCore().SetColor(color); } Color _OptionMenuImpl::GetColor(void) const { - ClearLastResult(); + ClearLastResult(); - return GetCore().GetColor(); + return GetCore().GetColor(); } result _OptionMenuImpl::SetMaxVisibleItemsCount(int maxItemsCount) { - ClearLastResult(); + ClearLastResult(); - return GetCore().SetMaxVisibleItemsCount(maxItemsCount); + return GetCore().SetMaxVisibleItemsCount(maxItemsCount); } int _OptionMenuImpl::GetMaxVisibleItemsCount(void) const { - ClearLastResult(); + ClearLastResult(); - return GetCore().GetPropertyMaxVisibleItemsCount().ToInt(); + return GetCore().GetPropertyMaxVisibleItemsCount().ToInt(); } 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."); + "[E_INVALID_OPERATION] There is no item to show."); - _WindowImpl::OnAttachedToMainTree(); - return E_SUCCESS; + return _WindowImpl::OnAttachedToMainTree();; } const char* diff --git a/src/ui/controls/FUiCtrl_OptionMenuModel.cpp b/src/ui/controls/FUiCtrl_OptionMenuModel.cpp index db8fa4e..e2f23e4 100644 --- a/src/ui/controls/FUiCtrl_OptionMenuModel.cpp +++ b/src/ui/controls/FUiCtrl_OptionMenuModel.cpp @@ -23,9 +23,6 @@ #include #include "FUiCtrl_OptionMenuModel.h" -static const int DEFAULT_ITEM_COUNT = 32; -const int INVALID_INDEX = -1; -const int MAX_MAIN_ITEM_COUNT = 12; const int MAX_SUB_ITEM_COUNT = 32; using namespace Tizen::Graphics; @@ -47,7 +44,7 @@ _OptionMenuModel::~_OptionMenuModel(void) result _OptionMenuModel::Construct(void) { - result r = __items.Construct(DEFAULT_ITEM_COUNT); + result r = __items.Construct(); SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to construct ArrayList."); return r; diff --git a/src/ui/controls/FUiCtrl_OptionMenuPresenter.cpp b/src/ui/controls/FUiCtrl_OptionMenuPresenter.cpp index 59b1603..f5a7fdf 100644 --- a/src/ui/controls/FUiCtrl_OptionMenuPresenter.cpp +++ b/src/ui/controls/FUiCtrl_OptionMenuPresenter.cpp @@ -445,7 +445,8 @@ int _OptionMenuPresenter::CalculateShowItemCount(void) { int itemMaxCount = 0; - GET_SHAPE_CONFIG(CONTEXTMENU::ITEM_MAX_COUNT, _CONTROL_ORIENTATION_PORTRAIT, itemMaxCount); + _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation(); + GET_SHAPE_CONFIG(CONTEXTMENU::ITEM_MAX_COUNT, orientation, itemMaxCount); int maxVisibleCount = __pOptionMenu->GetShowItemCount(); @@ -486,7 +487,8 @@ _OptionMenuPresenter::CalculateRect(void) if (__pOptionMenu->GetLayout() == _CONTROL_ORIENTATION_LANDSCAPE) { screen.SetSize(screen.height, screen.width); - } + } + AdjustItemLayout(); bodyRect.width = __layoutSize.width + bodyLeftMargin + bodyRightMargin; @@ -691,9 +693,9 @@ _OptionMenuPresenter::Draw(void) screenSize.width = temp.height; screenSize.height = temp.width; } - int maxItem = 0; - GET_SHAPE_CONFIG(OPTIONMENU::MAX_OPTIONMENU_SHOW_ITEM, orientation, maxItem); - __pOptionMenu->SetPropertyMaxVisibleItemsCount(maxItem); + //int maxItem = 0; + //GET_SHAPE_CONFIG(OPTIONMENU::MAX_OPTIONMENU_SHOW_ITEM, orientation, maxItem); + //__pOptionMenu->SetPropertyMaxVisibleItemsCount(maxItem); Tizen::Graphics::FloatRectangle bodyRect = __pOptionMenu->GetBodyRect(); diff --git a/src/ui/inc/FUiCtrl_OptionMenu.h b/src/ui/inc/FUiCtrl_OptionMenu.h index fe7c67f..245a1ff 100644 --- a/src/ui/inc/FUiCtrl_OptionMenu.h +++ b/src/ui/inc/FUiCtrl_OptionMenu.h @@ -65,7 +65,7 @@ class _OptionMenuItem; class _OSP_EXPORT_ _OptionMenu : public _Window - , public _IActionEventListener + , public _IActionEventListener , virtual public Tizen::Base::Runtime::IEventListener , virtual public _IUiEventListener , virtual public _IUiEventPreviewer @@ -114,10 +114,10 @@ public: 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 InsertItemAt(int mainIndex, const Base::String& text, int actionId, const Tizen::Graphics::Bitmap* pNormalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap); - result SetItemAt(int mainIndex, const Base::String& text, int actionId, const Tizen::Graphics::Bitmap* pNormalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap); - int GetItemIndexFromActionId(int actionId) const; + 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 InsertItemAt(int mainIndex, const Tizen::Base::String& text, int actionId, const Tizen::Graphics::Bitmap* pNormalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap); + result SetItemAt(int mainIndex, const Tizen::Base::String& text, int actionId, const Tizen::Graphics::Bitmap* pNormalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap); + int GetItemIndexFromActionId(int actionId) 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); @@ -129,11 +129,11 @@ public: bool IsSubMenuShown(void) const; result DestroySubMenu(void); 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); + 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); + const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap); result RemoveItemAt(int index); - void RemoveAllItems(void); + void RemoveAllItems(void); int GetItemCount(void) const; result SetShowItemCount(int count); int GetShowItemCount(void) const; @@ -149,8 +149,8 @@ public: result SetTextColor(enum OptionMenuCoreItemStatus status, const Tizen::Graphics::Color& color); Tizen::Graphics::Color GetTextColor(enum OptionMenuCoreItemStatus status) const; result SetColor(const Tizen::Graphics::Color& color); - Tizen::Graphics::Color GetColor(void) const; - result SetMaxVisibleItemsCount(int maxItemsCount); + Tizen::Graphics::Color GetColor(void) const; + result SetMaxVisibleItemsCount(int maxItemsCount); result SetItemColor(enum OptionMenuCoreItemStatus status, const Tizen::Graphics::Color& color); Tizen::Graphics::Color GetItemColor(enum OptionMenuCoreItemStatus status) const; result AddActionEventListener(const Tizen::Ui::Controls::_IActionEventListener& listener); @@ -181,6 +181,8 @@ public: virtual void OnChangeLayout(_ControlOrientation orientation); virtual void OnOwnerChanged(_Control* pOldOwner); + void OnActivated(void); + void OnDeactivated(void); virtual bool OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element); virtual bool OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element); @@ -201,13 +203,13 @@ public: _ScrollPanel* GetScrollPanel(void); -// virtual bool OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo); -// virtual bool OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo); -// virtual bool OnFocusGained(const _Control& source); -// virtual bool OnFocusLost(const _Control& source); -// virtual void OnDrawFocus(void); -// void OnFocusModeStateChanged(void); -// bool IsChildControlFocusManage(void) const; + // virtual bool OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo); + virtual bool OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo); + // virtual bool OnFocusGained(const _Control& source); + // virtual bool OnFocusLost(const _Control& source); + // virtual void OnDrawFocus(void); + // void OnFocusModeStateChanged(void); + // bool IsChildControlFocusManage(void) const; protected: result SetPresenter(const _OptionMenuPresenter& OptionMenuPresenter); @@ -218,7 +220,6 @@ private: void SetAllAccessibilityElement(void); void RemoveAllAccessibilityElement(void); -private: _OptionMenu(const _OptionMenu& rhs); _OptionMenu& operator =(const _OptionMenu& rhs); @@ -228,16 +229,17 @@ private: int __showItemMaxCount; bool __isAttachedToMainTree; bool __ownerInputEnableState; + bool __isInOpenedState; -// attribute for position fo the window + // attribute for position fo the window Tizen::Graphics::FloatRectangle __windowRect; // OptionMenu window in the whole screen area Tizen::Graphics::FloatRectangle __bodyRect; // body area relative to window Tizen::Graphics::FloatRectangle __itemRect; // item area relative to window -// attribute for event + // attribute for event _ActionEvent* __pActionEvent; -// attribute for drawing + // attribute for drawing Tizen::Graphics::Bitmap* __pBackgroundNormalBitmap; Tizen::Graphics::Bitmap* __pBackgroundEffectBitmap; enum _ControlOrientation __layout; diff --git a/src/ui/inc/FUiCtrl_OptionMenuModel.h b/src/ui/inc/FUiCtrl_OptionMenuModel.h index a6e9f04..c9a3751 100644 --- a/src/ui/inc/FUiCtrl_OptionMenuModel.h +++ b/src/ui/inc/FUiCtrl_OptionMenuModel.h @@ -69,6 +69,7 @@ private: private: Tizen::Base::Collection::ArrayList __items; + static const int INVALID_INDEX = -1; }; // _OptionMenuModel }}} // Tizen::Ui::Controls -- 2.7.4