Fixed Nabi Issues N_SE-56966,56735
[apps/osp/Internet.git] / src / IntDropDownCustomItem.cpp
index 038fec4..46b51ec 100644 (file)
-//\r
-\r
-// Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
-//\r
-// Licensed under the Flora License, Version 1.0 (the License);\r
-// you may not use this file except in compliance with the License.\r
-// You may obtain a copy of the License at\r
-//\r
-//     http://floralicense.org/license/\r
-//\r
-// Unless required by applicable law or agreed to in writing, software\r
-// distributed under the License is distributed on an AS IS BASIS,\r
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-// See the License for the specific language governing permissions and\r
-// limitations under the License.\r
-//\r
-\r
-/*\r
- *@file:    IntDropDownCustomItem\r
- *@brief: To create Drop Down custom item\r
- *\r
- */\r
-\r
-#include <FApp.h>\r
-#include <FUiControls.h>\r
-\r
-#include "IntDropDownCustomItem.h"\r
-#include "IntTypes.h"\r
-\r
-using namespace Tizen::App;\r
-using namespace Tizen::Base;\r
-using namespace Tizen::Graphics;\r
-using namespace Tizen::Ui::Controls;\r
-\r
-static const wchar_t* IDB_LIST_EXPAND_CLOSED = L"00_circle_button_Expand_closed.png";\r
-static const wchar_t* IDB_LIST_EXPAND_CLOSED_PRESS = L"00_list_expand_closed_press.png";\r
-static const wchar_t* IDB_LIST_EXPAND_OPENED = L"00_circle_button_Expand_open.png";\r
-static const wchar_t* IDB_LIST_EXPAND_OPENED_PRESS = L"00_list_expand_opened_press.png";\r
-\r
-const int DropDownCustomItem::IDA_FORMAT_BITMAP = 101;\r
-const int DropDownCustomItem::IDA_FORMAT_MAIN_STRING = 102;\r
-const int DropDownCustomItem::IDA_FORMAT_SUB_STRING = 103;\r
-const int DropDownCustomItem::IDA_FORMAT_DROPPER = 104;\r
-\r
-\r
-DropDownCustomItem::DropDownCustomItem(void)\r
-{\r
-       __width = 0;\r
-       __height = 0;\r
-       __mainText = L"";\r
-       __subText = L"";\r
-       __currentState = DROP_DOWN__ITEM_STATE_CLOSED;\r
-}\r
-\r
-DropDownCustomItem::~DropDownCustomItem(void)\r
-{\r
-\r
-}\r
-\r
-result\r
-DropDownCustomItem::Construct(int width)\r
-{\r
-       result r = E_SUCCESS;\r
-       __width = width;\r
-       __height = 140;\r
-       Dimension dim(__width, __height);\r
-       r = CustomItem::Construct(dim, LIST_ANNEX_STYLE_NORMAL);\r
-       return r;\r
-}\r
-\r
-void\r
-DropDownCustomItem::SetMainText(const Tizen::Base::String& text)\r
-{\r
-       __mainText = text;\r
-}\r
-\r
-String\r
-DropDownCustomItem::GetMainText(void)\r
-{\r
-       return __mainText;\r
-}\r
-\r
-void\r
-DropDownCustomItem::SetSubText(const Tizen::Base::String& text)\r
-{\r
-       __subText = text;\r
-}\r
-\r
-String\r
-DropDownCustomItem::GetSubText(void)\r
-{\r
-       return __subText;\r
-}\r
-\r
-result\r
-DropDownCustomItem::Make()\r
-{\r
-       AppLogDebug("DropDownCustomItem::Make entered");\r
-       result r = E_FAILURE;\r
-       EnrichedText* pMainEnText = null;\r
-       EnrichedText* pSubEnText = null;\r
-       TextElement* pMainTextElement = null;\r
-       TextElement* pSubTextElement = null;\r
-       Font mainTextFont;\r
-       Font subTextFont;\r
-       Tizen::Graphics::Bitmap* pDropperBitmapNormal = null;\r
-       Tizen::Graphics::Bitmap* pDropperBitmapPressed = null;\r
-\r
-       pMainEnText = new(std::nothrow) EnrichedText();\r
-       r = pMainEnText->Construct(Dimension(__width - 80, 54));\r
-       if(IsFailed(r))\r
-       {\r
-               delete pMainEnText;\r
-               return E_FAILURE;\r
-       }\r
-\r
-       pMainTextElement = new(std::nothrow) TextElement();\r
-       pMainTextElement->Construct(__mainText);\r
-\r
-       mainTextFont.Construct(FONT_STYLE_BOLD, 44);\r
-\r
-       Color pressedTextColor = CUSTOM_COLOR_LISTVIEW_TEXT;\r
-       pMainTextElement->SetFont(mainTextFont);\r
-       pMainTextElement->SetTextColor(CUSTOM_COLOR_TRANSPARENT);\r
-       pMainEnText->Add(*pMainTextElement);\r
-\r
-       pSubEnText = new(std::nothrow) EnrichedText();\r
-       r = pSubEnText->Construct(Dimension(__width - 80, 42));\r
-       if(IsFailed(r))\r
-       {\r
-               pMainEnText->RemoveAll(true);\r
-               delete pMainEnText;\r
-               delete pSubEnText;\r
-               return E_FAILURE;\r
-       }\r
-\r
-       pSubTextElement = new(std::nothrow) TextElement();\r
-       pSubTextElement->Construct(__subText);\r
-\r
-\r
-       subTextFont.Construct(FONT_STYLE_PLAIN, 32);\r
-\r
-       pSubTextElement->SetFont(subTextFont);\r
-       pSubTextElement->SetTextColor(CUSTOM_COLOR_GREY);\r
-       pSubEnText->Add(*pSubTextElement);\r
-\r
-       r = AddElement(Rectangle(26, 22, __width - 126, 54), IDA_FORMAT_MAIN_STRING, *pMainEnText);\r
-       r = AddElement(Rectangle(26, 76, __width - 126, 42), IDA_FORMAT_SUB_STRING, *pSubEnText);\r
-       if(IsFailed(r))\r
-       {\r
-               pMainEnText->RemoveAll(true);\r
-               pSubEnText->RemoveAll(true);\r
-               delete pMainEnText;\r
-               delete pSubEnText;\r
-               return E_FAILURE;\r
-       }\r
-       AppResource* pAppResource = UiApp::GetInstance()->GetAppResource();\r
-       if (pAppResource)\r
-       {\r
-               if (GetCurState() == DROP_DOWN__ITEM_STATE_CLOSED)\r
-               {\r
-                       pDropperBitmapNormal = pAppResource->GetBitmapN(IDB_LIST_EXPAND_CLOSED, BITMAP_PIXEL_FORMAT_ARGB8888);\r
-                       pDropperBitmapPressed = pAppResource->GetBitmapN(IDB_LIST_EXPAND_CLOSED_PRESS, BITMAP_PIXEL_FORMAT_ARGB8888);\r
-               }\r
-               else\r
-               {\r
-                       pDropperBitmapNormal = pAppResource->GetBitmapN(IDB_LIST_EXPAND_OPENED, BITMAP_PIXEL_FORMAT_ARGB8888);\r
-                       pDropperBitmapPressed = pAppResource->GetBitmapN(IDB_LIST_EXPAND_OPENED_PRESS, BITMAP_PIXEL_FORMAT_ARGB8888);\r
-               }\r
-\r
-               AddElement(Rectangle(__width - 98, (__height - 74) / 2, 74, 74), IDA_FORMAT_DROPPER, *pDropperBitmapNormal, pDropperBitmapPressed, pDropperBitmapNormal);\r
-               delete pDropperBitmapNormal;\r
-               delete pDropperBitmapPressed;\r
-       }\r
-\r
-       SetElementSelectionEnabled(IDA_FORMAT_MAIN_STRING, true);\r
-       SetElementSelectionEnabled(IDA_FORMAT_SUB_STRING, true);\r
-       SetElementSelectionEnabled(IDA_FORMAT_DROPPER, true);\r
-\r
-       pSubEnText->RemoveAllTextElements(true);\r
-       pMainEnText->RemoveAllTextElements(true);\r
-\r
-       delete pMainEnText;\r
-       delete pSubEnText;\r
-\r
-       return E_SUCCESS;\r
-}\r
-\r
-DropDownItemState\r
-DropDownCustomItem::GetCurState(void)\r
-{\r
-       return __currentState;\r
-}\r
-\r
-void\r
-DropDownCustomItem::SetCurState(DropDownItemState state)\r
-{\r
-       __currentState = state;\r
-}\r
+//
+
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.1 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/*
+ *@file:    IntDropDownCustomItem
+ *@brief: To create Drop Down custom item
+ *
+ */
+
+#include <FApp.h>
+#include <FUiControls.h>
+
+#include "IntCommonLib.h"
+#include "IntDropDownCustomItem.h"
+#include "IntTypes.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Graphics;
+using namespace Tizen::Ui::Controls;
+
+static const wchar_t* IDB_LIST_EXPAND_CLOSED = L"00_button_expand_closed.png";
+static const wchar_t* IDB_LIST_EXPAND_CLOSED_PRESS = L"00_button_expand_closed_press.png";
+static const wchar_t* IDB_LIST_EXPAND_OPENED = L"00_button_expand_opened.png";
+static const wchar_t* IDB_LIST_EXPAND_OPENED_PRESS = L"00_button_expand_opened_press.png";
+
+const int DropDownCustomItem::IDA_FORMAT_BITMAP = 101;
+const int DropDownCustomItem::IDA_FORMAT_MAIN_STRING = 102;
+const int DropDownCustomItem::IDA_FORMAT_SUB_STRING = 103;
+const int DropDownCustomItem::IDA_FORMAT_DROPPER = 104;
+
+
+DropDownCustomItem::DropDownCustomItem(void)
+{
+       __width = 0;
+       __height = 0;
+       __mainText = L"";
+       __subText = L"";
+       __currentState = DROP_DOWN__ITEM_STATE_CLOSED;
+}
+
+DropDownCustomItem::~DropDownCustomItem(void)
+{
+
+}
+
+result
+DropDownCustomItem::Construct(int width)
+{
+       result r = E_SUCCESS;
+       __width = width;
+       __fontSize = CommonUtil::GetFontSize();
+       __height = 140 + (__fontSize - 44);
+       Dimension dim(__width, __height);
+       r = CustomItem::Construct(dim, LIST_ANNEX_STYLE_NORMAL);
+       return r;
+}
+
+void
+DropDownCustomItem::SetMainText(const Tizen::Base::String& text)
+{
+       __mainText = text;
+}
+
+String
+DropDownCustomItem::GetMainText(void)
+{
+       return __mainText;
+}
+
+void
+DropDownCustomItem::SetSubText(const Tizen::Base::String& text)
+{
+       __subText = text;
+}
+
+String
+DropDownCustomItem::GetSubText(void)
+{
+       return __subText;
+}
+
+result
+DropDownCustomItem::Make()
+{
+       AppLogDebug("DropDownCustomItem::Make entered");
+       result r = E_FAILURE;
+       EnrichedText* pMainEnText = null;
+       EnrichedText* pSubEnText = null;
+       TextElement* pMainTextElement = null;
+       TextElement* pSubTextElement = null;
+       Font mainTextFont;
+       Font subTextFont;
+       Tizen::Graphics::Bitmap* pDropperBitmapNormal = null;
+       Tizen::Graphics::Bitmap* pDropperBitmapPressed = null;
+
+       pMainEnText = new(std::nothrow) EnrichedText();
+       r = pMainEnText->Construct(Dimension(__width - 80, 54 + (__fontSize - 44)));
+       if(IsFailed(r))
+       {
+               delete pMainEnText;
+               return E_FAILURE;
+       }
+
+       pMainTextElement = new(std::nothrow) TextElement();
+       pMainTextElement->Construct(__mainText);
+
+       mainTextFont.Construct(FONT_STYLE_BOLD, __fontSize);
+
+       Color pressedTextColor = CUSTOM_COLOR_LISTVIEW_TEXT;
+       pMainTextElement->SetFont(mainTextFont);
+       pMainTextElement->SetTextColor(CUSTOM_COLOR_TRANSPARENT);
+       pMainEnText->Add(*pMainTextElement);
+
+       pSubEnText = new(std::nothrow) EnrichedText();
+       r = pSubEnText->Construct(Dimension(__width - 80, 42));
+       if(IsFailed(r))
+       {
+               pMainEnText->RemoveAll(true);
+               delete pMainEnText;
+               delete pSubEnText;
+               return E_FAILURE;
+       }
+
+       pSubTextElement = new(std::nothrow) TextElement();
+       r = pSubTextElement->Construct(__subText);
+       if(IsFailed(r))
+       {
+               pMainEnText->RemoveAll(true);
+               delete pMainEnText;
+               delete pSubEnText;
+               delete pSubTextElement;
+               return E_FAILURE;
+       }
+
+
+       subTextFont.Construct(FONT_STYLE_PLAIN, 32);
+
+       pSubTextElement->SetFont(subTextFont);
+       pSubTextElement->SetTextColor(CUSTOM_COLOR_GREY);
+       pSubEnText->Add(*pSubTextElement);
+
+       r = AddElement(Rectangle(26, 22, __width - 126, 72 + (__fontSize - 44)), IDA_FORMAT_MAIN_STRING, *pMainEnText);
+       r = AddElement(Rectangle(26, 76 + (__fontSize - 44), __width - 126, 42), IDA_FORMAT_SUB_STRING, *pSubEnText);
+       if(IsFailed(r))
+       {
+               pMainEnText->RemoveAll(true);
+               pSubEnText->RemoveAll(true);
+               delete pMainEnText;
+               delete pSubEnText;
+               return E_FAILURE;
+       }
+       AppResource* pAppResource = UiApp::GetInstance()->GetAppResource();
+       if (pAppResource)
+       {
+               if (GetCurState() == DROP_DOWN__ITEM_STATE_CLOSED)
+               {
+                       pDropperBitmapNormal = pAppResource->GetBitmapN(IDB_LIST_EXPAND_CLOSED, BITMAP_PIXEL_FORMAT_ARGB8888);
+                       pDropperBitmapPressed = pAppResource->GetBitmapN(IDB_LIST_EXPAND_CLOSED_PRESS, BITMAP_PIXEL_FORMAT_ARGB8888);
+               }
+               else
+               {
+                       pDropperBitmapNormal = pAppResource->GetBitmapN(IDB_LIST_EXPAND_OPENED, BITMAP_PIXEL_FORMAT_ARGB8888);
+                       pDropperBitmapPressed = pAppResource->GetBitmapN(IDB_LIST_EXPAND_OPENED_PRESS, BITMAP_PIXEL_FORMAT_ARGB8888);
+               }
+
+               AddElement(Rectangle(__width - pDropperBitmapNormal->GetWidth() - 12, (__height - pDropperBitmapNormal->GetHeight()) / 2 +  (__fontSize - 44)/2, pDropperBitmapNormal->GetWidth(), pDropperBitmapNormal->GetHeight()), IDA_FORMAT_DROPPER, *pDropperBitmapNormal, pDropperBitmapNormal, pDropperBitmapNormal);
+               delete pDropperBitmapNormal;
+               delete pDropperBitmapPressed;
+       }
+
+//     SetElementSelectionEnabled(IDA_FORMAT_MAIN_STRING, true);
+//     SetElementSelectionEnabled(IDA_FORMAT_SUB_STRING, true);
+//     SetElementSelectionEnabled(IDA_FORMAT_DROPPER, true);
+
+       pSubEnText->RemoveAllTextElements(true);
+       pMainEnText->RemoveAllTextElements(true);
+
+       delete pMainEnText;
+       delete pSubEnText;
+
+       return E_SUCCESS;
+}
+
+DropDownItemState
+DropDownCustomItem::GetCurState(void)
+{
+       return __currentState;
+}
+
+void
+DropDownCustomItem::SetCurState(DropDownItemState state)
+{
+       __currentState = state;
+}