-//\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
-//!Internet MultipleWindowForm class\r
-/*@file: MultipleWindowForm.cpp\r
- *@brief: The MultipleWindowForm provides multiple instance of mainscenes and displays them in a Listview\r
- *\r
- */\r
-\r
-#include <FAppUiApp.h>\r
-#include <FUiScenes.h>\r
-\r
-#include "IntCommonLib.h"\r
-#include "IntConfirmationPopup.h"\r
-#include "IntMainForm.h"\r
-#include "IntMultipleWindowForm.h"\r
-#include "IntMultipleWindowPresentationModel.h"\r
-#include "IntSceneRegister.h"\r
-\r
-using namespace Tizen::App;\r
-using namespace Tizen::Base;\r
-using namespace Tizen::Base::Collection;\r
-using namespace Tizen::Graphics;\r
-using namespace Tizen::Ui;\r
-using namespace Tizen::Ui::Controls;\r
-using namespace Tizen::Ui::Scenes;\r
-\r
-static const int W_ICON_IMAGE_WIDTH = 72;\r
-\r
-MultipleWindowForm::MultipleWindowForm(void)\r
-: __pList(null)\r
-, __pListIconImage(null)\r
-, __pListDeleteImage(null)\r
-{\r
-}\r
-\r
-MultipleWindowForm::~MultipleWindowForm(void)\r
-{\r
- if (__pListIconImage)\r
- {\r
- delete __pListIconImage;\r
- __pListIconImage = null;\r
- }\r
- if (__pListDeleteImage)\r
- {\r
- delete __pListDeleteImage;\r
- __pListDeleteImage = null;\r
- }\r
-}\r
-\r
-bool\r
-MultipleWindowForm::Initialize(void)\r
-{\r
- result r = E_SUCCESS;\r
-\r
- r = Construct(L"IDL_MULTIPLE_WINDOW");\r
- if (r == E_SUCCESS)\r
- {\r
- return true;\r
- }\r
- else\r
- {\r
- return false;\r
- }\r
-}\r
-\r
-result\r
-MultipleWindowForm::OnInitializing(void)\r
-{\r
- result r = E_SUCCESS;\r
- FooterItem closeButton;\r
- FooterItem newButton;\r
-\r
- SceneManager* pSceneManager = SceneManager::GetInstance();\r
-\r
- if (pSceneManager == null)\r
- {\r
- return E_FAILURE;\r
- }\r
-\r
- Footer* pFooter = GetFooter();\r
-\r
- if (pFooter == NULL)\r
- {\r
- return E_FAILURE;\r
- }\r
-\r
- SetFormStyle(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR | FORM_STYLE_HEADER | FORM_STYLE_FOOTER);\r
-\r
- r = pSceneManager->AddSceneEventListener(IDSCN_MULTIPLE_WINDOW, *this);\r
-\r
- // Setup back event listener\r
- SetFormBackEventListener(this);\r
- pFooter->AddActionEventListener(*this);\r
-\r
- AppResource* pAppResource = Application::GetInstance()->GetAppResource();\r
-\r
- if (pAppResource)\r
- {\r
- __pListIconImage = pAppResource->GetBitmapN(L"ListIcon.png");\r
- __pListDeleteImage = pAppResource->GetBitmapN(L"deleteIcon.png");\r
- }\r
-\r
- __pList = static_cast< ListView* >(GetControl(L"IDC_LISTVIEW"));\r
-\r
- if (__pList != null)\r
- {\r
- __pList->SetItemProvider(*this);\r
- __pList->AddListViewItemEventListener(*this);\r
- }\r
-\r
- AddOrientationEventListener(*this);\r
-// r = pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);\r
- r = closeButton.Construct(IDA_BUTTON_CLOSEALL);\r
- r = closeButton.SetText(CommonUtil::GetString(L"IDS_BR_CLOSE_ALL"));\r
- r = pFooter->AddItem(closeButton);\r
- r = newButton.Construct(IDA_BUTTON_NEW);\r
- r = newButton.SetText(CommonUtil::GetString(L"IDS_BR_SK1_NEW_WINDOW"));\r
- r = pFooter->AddItem(newButton);\r
-\r
- return r;\r
-}\r
-\r
-void\r
-MultipleWindowForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)\r
-{\r
- if (MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount() >= 9)\r
- {\r
- GetFooter()->SetItemEnabled(1,false);\r
- }\r
- else\r
- {\r
- GetFooter()->SetItemEnabled(1,true);\r
- }\r
- if (__pList)\r
- {\r
- __pList->UpdateList();\r
- }\r
- GetFooter()->Invalidate(true);\r
- return;\r
-}\r
-\r
-void\r
-MultipleWindowForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)\r
-{\r
- if (__pListIconImage)\r
- {\r
- delete __pListIconImage;\r
- __pListIconImage = NULL;\r
- }\r
- return;\r
-}\r
-\r
-result\r
-MultipleWindowForm::OnTerminating(void)\r
-{\r
- result r = E_SUCCESS;\r
-\r
- if (__pListIconImage)\r
- {\r
- delete __pListIconImage;\r
- __pListIconImage = NULL;\r
- }\r
- if (__pListDeleteImage)\r
- {\r
- delete __pListDeleteImage;\r
- __pListDeleteImage = NULL;\r
- }\r
-\r
- return r;\r
-}\r
-\r
-void\r
-MultipleWindowForm::OnActionPerformed(const Control& source, int actionId)\r
-{\r
- SceneManager* pSceneManager = SceneManager::GetInstance();\r
-\r
- if (pSceneManager == null)\r
- {\r
- return;\r
- }\r
-\r
- String closeWarning = CommonUtil::GetString(L"IDS_BR_CLOSE_ALL_WINDOWS_Q");\r
-\r
- switch (actionId)\r
- {\r
- case IDA_BUTTON_NEW:\r
- {\r
- WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();\r
-\r
- if (pNewWindowInfo == null)\r
- {\r
- return;\r
- }\r
- result r = E_SUCCESS;\r
- SceneManager* pSceneManager = SceneManager::GetInstance();\r
- if (pSceneManager == NULL)\r
- {\r
- return;\r
- }\r
- ArrayList* pArgList = new(std::nothrow) ArrayList();\r
- if (pArgList == NULL)\r
- {\r
- return;\r
- }\r
- pArgList->Construct();\r
-\r
- pArgList->Add(*pNewWindowInfo);\r
- r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);\r
- if (pArgList != null)\r
- {\r
- delete pArgList;\r
- pArgList = null;\r
- }\r
- if(IsFailed(r))\r
- {\r
- AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));\r
- return;\r
- }\r
- }\r
- break;\r
-\r
- case IDA_BUTTON_BACK:\r
- {\r
- String* pSelectedScene = NULL;\r
- Object* value = NULL;\r
- MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &value);\r
- pSelectedScene = (String*) value;\r
-\r
- if (pSelectedScene)\r
- {\r
- result r = pSceneManager->GoBackward(BackwardSceneTransition(*pSelectedScene, SCENE_TRANSITION_ANIMATION_TYPE_NONE));\r
- delete pSelectedScene;\r
- pSelectedScene = null;\r
- if(IsFailed(r))\r
- {\r
- AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));\r
- return;\r
- }\r
- }\r
- }\r
- break;\r
-\r
- case IDA_BUTTON_CLOSEALL:\r
- {\r
- __pConfirmationPopup = new(std::nothrow) ConfirmationPopup();\r
- __pConfirmationPopup->Initialize();\r
- __pConfirmationPopup->RemoveActionListener(*this);\r
- __pConfirmationPopup->AddActionListener(*this);\r
- __pConfirmationPopup->setMessage(closeWarning);\r
- __pConfirmationPopup->Show();\r
-\r
- }\r
- break;\r
- case IDA_CONFIRMATION_NO:\r
- {\r
- __pConfirmationPopup->SetShowState(false);\r
- __pConfirmationPopup->Show();\r
- }\r
- break;\r
- case IDA_CONFIRMATION_YES:\r
- {\r
- ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();\r
- if (pAllWindowList == NULL)\r
- {\r
- return;\r
- }\r
- int totalCount = pAllWindowList->GetCount();\r
-\r
- for (int count = 0; count < totalCount; count++)\r
- {\r
- WindowInfo* pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));\r
- SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);\r
- }\r
- pAllWindowList->RemoveAll(true);\r
- WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();\r
-\r
- if (pNewWindowInfo == null)\r
- {\r
- return;\r
- }\r
- result r = E_SUCCESS;\r
- SceneManager* pSceneManager = SceneManager::GetInstance();\r
- if (pSceneManager == NULL)\r
- {\r
- return;\r
- }\r
- ArrayList* pArgList = new(std::nothrow) ArrayList();\r
- if (pArgList == NULL)\r
- {\r
- return;\r
- }\r
- r = pArgList->Construct();\r
- if (r == E_SUCCESS)\r
- {\r
- pArgList->Add(*pNewWindowInfo);\r
- result r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);\r
- if (pArgList != null)\r
- {\r
- delete pArgList;\r
- pArgList = null;\r
- }\r
- if(IsFailed(r))\r
- {\r
- AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));\r
- return;\r
- }\r
- }\r
- __pConfirmationPopup->SetShowState(false);\r
- __pConfirmationPopup->Show();\r
- }\r
- break;\r
- default:\r
- break;\r
- }\r
-\r
-}\r
-\r
-void\r
-MultipleWindowForm::OnFormBackRequested(Form& source)\r
-{\r
-\r
- String* pSelectedScene = NULL;\r
- Object* value = NULL;\r
-\r
- SceneManager* pSceneManager = SceneManager::GetInstance();\r
- if (pSceneManager == null)\r
- {\r
- return;\r
- }\r
-\r
- MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &value);\r
- pSelectedScene = (String*) value;\r
- if (pSelectedScene != NULL)\r
- {\r
- result r = pSceneManager->GoBackward(BackwardSceneTransition(*pSelectedScene, SCENE_TRANSITION_ANIMATION_TYPE_NONE));\r
-// delete pSelectedScene;\r
- if(IsFailed(r))\r
- {\r
- AppLogDebug("MultipleWindowForm::OnFormBackRequested GoForward failed %s",GetErrorMessage(r));\r
- return;\r
- }\r
- }\r
- return;\r
-}\r
-\r
-void\r
-MultipleWindowForm::OnListViewContextItemStateChanged(ListView& listView, int index, int elementId, ListContextItemStatus state)\r
-{\r
- return;\r
-}\r
-\r
-void\r
-MultipleWindowForm::OnListViewItemStateChanged(ListView& listView, int index, int elementId, ListItemStatus status)\r
-{\r
- result r = E_SUCCESS;\r
- ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();\r
- int count = 0;\r
-\r
- if (elementId == IDA_FORMAT_DELETE_BITMAP)\r
- {\r
- // get current scene ID and check if it is matching with deleted scene id\r
- WindowInfo* pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(index));\r
- String* pSelectedScene = NULL;\r
- Object* pValue = NULL;\r
-\r
- if (pWindowInfo)\r
- {\r
- SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);\r
- MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);\r
- pSelectedScene = (String*) pValue;\r
- pAllWindowList->RemoveAt(index, true);\r
- if (pSelectedScene->CompareTo(pWindowInfo->sceneID) == 0)\r
- {\r
- //set current scene id to last scene id\r
- int totalCount = pAllWindowList->GetCount() - 1;\r
- WindowInfo* pLastIndexWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(totalCount));\r
- if (pLastIndexWindowInfo != NULL)\r
- {\r
- String* pSelectedSceneID = new(std::nothrow) String(pLastIndexWindowInfo->sceneID);\r
- if (pSelectedSceneID != NULL)\r
- {\r
- MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) pSelectedSceneID);\r
-\r
- }\r
- }\r
- }\r
- }\r
-\r
- count = MultipleWindowPresentationModel::GetInstance()->GetInstance()->GetAllWindowArrayList()->GetCount();\r
-\r
- if (count >= 9)\r
- {\r
- GetFooter()->SetItemEnabled(1,false);\r
- }\r
- else\r
- {\r
- GetFooter()->SetItemEnabled(1,true);\r
- }\r
-\r
- if ( count <= 1)\r
- {\r
- GetFooter()->SetItemEnabled(0,false);\r
- }\r
-\r
- GetFooter()->Invalidate(true);\r
- __pList->RefreshList(index, LIST_REFRESH_TYPE_ITEM_REMOVE);\r
- __pList->UpdateList();\r
- }\r
- else if(elementId == IDA_FORMAT_BITMAP || elementId == IDA_FORMAT_TITLE_STRING\r
- || elementId == IDA_FORMAT_URL_STRING || elementId == -1)\r
- {\r
-\r
- // launch the browser\r
- WindowInfo* pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(index));\r
- if (pWindowInfo == NULL)\r
- {\r
- return;\r
- }\r
- SceneManager* pSceneManager = SceneManager::GetInstance();\r
- if (pSceneManager == NULL)\r
- {\r
- return;\r
- }\r
- ArrayList* pArgList = new(std::nothrow) ArrayList();\r
- if (pArgList == NULL)\r
- {\r
- return;\r
- }\r
- r = pArgList->Construct();\r
- if (IsFailed(r))\r
- {\r
- return;\r
- }\r
- pArgList->Add(*pWindowInfo);\r
- result r = pSceneManager->GoForward(ForwardSceneTransition(pWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);\r
-\r
- if (r == E_SUCCESS)\r
- {\r
- AppLogDebug("go forward success");\r
- }\r
- else\r
- {\r
- AppLogDebug("go forward failed");\r
- }\r
- if (pArgList != null)\r
- {\r
- delete pArgList;\r
- pArgList = null;\r
- }\r
-\r
- }\r
-\r
- return;\r
-}\r
-\r
-void\r
-MultipleWindowForm::OnListViewItemSwept(ListView& listView, int index, SweepDirection direction)\r
-{\r
- return;\r
-}\r
-\r
-void\r
-MultipleWindowForm::OnListViewItemLongPressed(ListView& listView, int index, int elementId, bool& invokeListViewItemCallback)\r
-{\r
- return;\r
-}\r
-\r
-ListItemBase*\r
-MultipleWindowForm::CreateItem(int index, int itemWidth)\r
-{\r
- Rectangle listImageRect;\r
- Rectangle pagetTitleRect;\r
- Rectangle pageURLRect;\r
- Rectangle deleteImageRect;\r
- String pageTitle(L"");\r
- String pageURL(L"");\r
- result r = E_SUCCESS;\r
- int width = W_ICON_IMAGE_WIDTH;\r
-\r
- AppResource* pAppResource = Application::GetInstance()->GetAppResource();\r
- ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;\r
- ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();\r
-\r
- if (pAllWindowList == null)\r
- {\r
- return null;\r
- }\r
- WindowInfo* pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(index));\r
- if(pWindowInfo == null)\r
- {\r
- return NULL;\r
- }\r
- CustomItem* pItem = new(std::nothrow) CustomItem();\r
- pageTitle = pWindowInfo->pageTitle;\r
- pageURL = pWindowInfo->pageUrl;\r
- if (pageURL.GetLength() == 0)\r
- {\r
- String nourl;\r
- pAppResource->GetString(L"IDS_BR_BODY_ABOUT_C_BLANK", nourl);\r
- pageURL = L"<"+ nourl +">";\r
- }\r
-\r
- Rectangle screenBounds = GetBounds();\r
- r = pItem->Construct(Dimension(itemWidth, 128), style);\r
- if (IsFailed(r))\r
- {\r
- return NULL;\r
- }\r
-\r
- if (pWindowInfo->pFavicon)\r
- {\r
-\r
- if( __pListIconImage != NULL)\r
- {\r
- delete __pListIconImage;\r
- __pListIconImage = null;\r
- }\r
-\r
- __pListIconImage = new Bitmap();\r
- __pListIconImage->Construct(*(pWindowInfo->pFavicon),Rectangle(0,0,pWindowInfo->pFavicon->GetWidth(),pWindowInfo->pFavicon->GetHeight()));\r
- }\r
- else\r
- {\r
- if( __pListIconImage != NULL)\r
- {\r
- delete __pListIconImage;\r
- __pListIconImage = null;\r
- }\r
-\r
- __pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");\r
- }\r
- AppLog("deleteimg %d %d",__pListDeleteImage->GetWidth(),__pListDeleteImage->GetHeight());\r
-\r
- listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28,width, 72);\r
- pagetTitleRect.SetBounds(listImageRect.x + width + 16,10, screenBounds.width - 2 * width - 64, 60);\r
- pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * width - 120, 48);\r
- deleteImageRect.SetBounds(screenBounds.width - __pListDeleteImage->GetWidth() - 24, (128 - __pListDeleteImage->GetHeight() - 8)/2, __pListDeleteImage->GetWidth() + 8, __pListDeleteImage->GetHeight() + 8);\r
- pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *__pListIconImage, null, null);\r
-\r
- if (pageTitle.CompareTo(L"") != 0)\r
- {\r
- pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, 44, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);\r
- }\r
-\r
- if (pageURL.CompareTo(L"") != 0)\r
- {\r
- pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);\r
- }\r
-\r
- if (pAllWindowList)\r
- {\r
- if (pAllWindowList->GetCount() > 1)\r
- {\r
- pItem->AddElement(deleteImageRect, IDA_FORMAT_DELETE_BITMAP, *__pListDeleteImage, null, null);\r
- pItem->SetElementSelectionEnabled(IDA_FORMAT_DELETE_BITMAP, true); \r
- }\r
- }\r
- return pItem;\r
-}\r
-\r
-bool\r
-MultipleWindowForm::DeleteItem(int index, ListItemBase* pItem, int itemWidth)\r
-{\r
- delete pItem;\r
- pItem = null;\r
- return true;\r
-}\r
-\r
-int\r
-MultipleWindowForm::GetItemCount(void)\r
-{\r
- ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();\r
- int windowCount = 0;\r
-\r
- if (pAllWindowList != null)\r
- {\r
- windowCount = pAllWindowList->GetCount();\r
- }\r
- if (windowCount < 2)\r
- {\r
- GetFooter()->SetItemEnabled(0, false);\r
- }\r
- else\r
- {\r
- GetFooter()->SetItemEnabled(0, true);\r
- }\r
- GetFooter()->Invalidate(true);\r
- return windowCount;\r
-}\r
-\r
-void\r
-MultipleWindowForm::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus)\r
-{\r
- if (__pList)\r
- {\r
- __pList->UpdateList();\r
- }\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.
+//
+
+//!Internet MultipleWindowForm class
+/*@file: MultipleWindowForm.cpp
+ *@brief: The MultipleWindowForm provides multiple instance of mainscenes and displays them in a Listview
+ *
+ */
+
+#include <FAppUiApp.h>
+#include <FUiScenes.h>
+
+#include "IntCommonLib.h"
+#include "IntConfirmationPopup.h"
+#include "IntMainForm.h"
+#include "IntMultipleWindowForm.h"
+#include "IntMultipleWindowPresentationModel.h"
+#include "IntSceneRegister.h"
+#include "IntSettingPresentationModel.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;
+using namespace Tizen::Ui::Scenes;
+
+static const int W_ICON_IMAGE_WIDTH = 72;
+
+MultipleWindowForm::MultipleWindowForm(void)
+: __pList(null)
+, __pListIconImage(null)
+, __pListDeleteImage(null)
+,__pConfirmationPopup(null)
+{
+ __startPosition.x = -1;
+ __startPosition.y = -1;
+ __fontSize = 44;
+}
+
+MultipleWindowForm::~MultipleWindowForm(void)
+{
+ if (__pListIconImage)
+ {
+ delete __pListIconImage;
+ __pListIconImage = null;
+ }
+ if (__pListDeleteImage)
+ {
+ delete __pListDeleteImage;
+ __pListDeleteImage = null;
+ }
+}
+
+bool
+MultipleWindowForm::Initialize(void)
+{
+ result r = E_SUCCESS;
+
+ r = Construct(L"IDL_MULTIPLE_WINDOW");
+ if (r == E_SUCCESS)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+result
+MultipleWindowForm::OnInitializing(void)
+{
+ result r = E_SUCCESS;
+ FooterItem closeButton;
+ FooterItem newButton;
+
+ __fontSize = CommonUtil::GetFontSize();
+ SceneManager* pSceneManager = SceneManager::GetInstance();
+
+ if (pSceneManager == null)
+ {
+ return E_FAILURE;
+ }
+
+ Footer* pFooter = GetFooter();
+
+ if (pFooter == NULL)
+ {
+ return E_FAILURE;
+ }
+
+// SetFormStyle(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR | FORM_STYLE_HEADER | FORM_STYLE_FOOTER);
+
+ r = pSceneManager->AddSceneEventListener(IDSCN_MULTIPLE_WINDOW, *this);
+
+ // Setup back event listener
+ SetFormBackEventListener(this);
+ pFooter->AddActionEventListener(*this);
+
+ AppResource* pAppResource = Application::GetInstance()->GetAppResource();
+
+ if (pAppResource)
+ {
+ __pListIconImage = pAppResource->GetBitmapN(L"ListIcon.png");
+ __pListDeleteImage = pAppResource->GetBitmapN(L"deleteIcon.png");
+ }
+
+ __pList = static_cast< ListView* >(GetControl(L"IDC_LISTVIEW"));
+
+ if (__pList != null)
+ {
+ __pList->SetItemProvider(*this);
+ __pList->AddListViewItemEventListener(*this);
+
+ }
+
+ AddOrientationEventListener(*this);
+// r = pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
+ r = closeButton.Construct(IDA_BUTTON_CLOSEALL);
+ r = closeButton.SetText(CommonUtil::GetString(L"IDS_BR_OPT_CLOSE_ALL"));
+ r = pFooter->AddItem(closeButton);
+ r = newButton.Construct(IDA_BUTTON_NEW);
+ r = newButton.SetText(CommonUtil::GetString(L"IDS_BR_OPT_NEW_WINDOW"));
+ r = pFooter->AddItem(newButton);
+
+ return r;
+}
+
+void
+MultipleWindowForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
+{
+ if (MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount() >= 9)
+ {
+ GetFooter()->SetItemEnabled(1,false);
+ }
+ else
+ {
+ GetFooter()->SetItemEnabled(1,true);
+ }
+ if (__pList)
+ {
+ __pList->UpdateList();
+ }
+ GetFooter()->Invalidate(true);
+ return;
+}
+
+void
+MultipleWindowForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
+{
+ if (__pListIconImage)
+ {
+ delete __pListIconImage;
+ __pListIconImage = NULL;
+ }
+ return;
+}
+
+result
+MultipleWindowForm::OnTerminating(void)
+{
+ result r = E_SUCCESS;
+
+ if (__pListIconImage)
+ {
+ delete __pListIconImage;
+ __pListIconImage = NULL;
+ }
+ if (__pListDeleteImage)
+ {
+ delete __pListDeleteImage;
+ __pListDeleteImage = NULL;
+ }
+
+ return r;
+}
+
+void
+MultipleWindowForm::OnActionPerformed(const Control& source, int actionId)
+{
+ SceneManager* pSceneManager = SceneManager::GetInstance();
+
+ if (pSceneManager == null)
+ {
+ return;
+ }
+
+ String closeWarning = CommonUtil::GetString(L"IDS_BR_POP_CLOSE_ALL_OPENED_WINDOWS_AND_GO_TO_THE_HOMEPAGE");
+
+ switch (actionId)
+ {
+ case IDA_BUTTON_NEW:
+ {
+ WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
+
+ if (pNewWindowInfo == null)
+ {
+ return;
+ }
+ result r = E_SUCCESS;
+ SceneManager* pSceneManager = SceneManager::GetInstance();
+ if (pSceneManager == NULL)
+ {
+ return;
+ }
+ ArrayList* pArgList = new(std::nothrow) ArrayList();
+ if (pArgList == NULL)
+ {
+ return;
+ }
+ pArgList->Construct();
+
+ pArgList->Add(*pNewWindowInfo);
+ r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
+ if (pArgList != null)
+ {
+ delete pArgList;
+ pArgList = null;
+ }
+ if(IsFailed(r))
+ {
+ AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
+ return;
+ }
+ }
+ break;
+
+ case IDA_BUTTON_BACK:
+ {
+ String* pSelectedScene = NULL;
+ Object* value = NULL;
+ MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &value);
+ pSelectedScene = (String*) value;
+
+ if (pSelectedScene)
+ {
+ result r = pSceneManager->GoBackward(BackwardSceneTransition(*pSelectedScene, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
+ delete pSelectedScene;
+ pSelectedScene = null;
+ if(IsFailed(r))
+ {
+ AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
+ return;
+ }
+ }
+ }
+ break;
+
+ case IDA_BUTTON_CLOSEALL:
+ {
+ if(__pConfirmationPopup)
+ {
+ delete __pConfirmationPopup;
+ __pConfirmationPopup = null;
+ }
+ if (!__pConfirmationPopup)
+ {
+ __pConfirmationPopup = new(std::nothrow) ConfirmationPopup();
+ __pConfirmationPopup->Initialize();
+
+ __pConfirmationPopup->RemoveActionListener(*this);
+ __pConfirmationPopup->AddActionListener(*this);
+ __pConfirmationPopup->setMessage(closeWarning);
+ __pConfirmationPopup->Show();
+ }
+ }
+ break;
+ case IDA_CONFIRMATION_NO:
+ {
+ __pConfirmationPopup->SetShowState(false);
+ __pConfirmationPopup->Show();
+
+ delete __pConfirmationPopup;
+ __pConfirmationPopup = null;
+
+ }
+ break;
+ case IDA_CONFIRMATION_YES:
+ {
+ ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
+ if (pAllWindowList == NULL)
+ {
+ return;
+ }
+ int totalCount = pAllWindowList->GetCount();
+
+ for (int count = 0; count < totalCount; count++)
+ {
+ WindowInfo* pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
+ SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
+ }
+ pAllWindowList->RemoveAll(true);
+ String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
+ if (homePage == (L"IDS_BR_BODY_MOST_VISITED_SITES") || homePage == (L"IDS_BR_BODY_BLANK_PAGE"))
+ {
+ homePage = L"";
+ }
+ else if (homePage == CommonUtil::GetString(L"IDS_BR_BODY_USER_HOMEPAGE"))
+ {
+ AppLog("InternetApp::OnAppInitialized homaepage = userhomepage");
+ homePage = SettingPresentationModel::GetInstance()->GetFavoriteUrl();
+ AppLog("InternetApp::OnAppInitialized fav URL = %ls ",homePage.GetPointer());
+ }
+
+ WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN(homePage);
+
+ if (pNewWindowInfo == null)
+ {
+ return;
+ }
+ pNewWindowInfo->isAppcontrolTriggered = true;
+ result r = E_SUCCESS;
+ SceneManager* pSceneManager = SceneManager::GetInstance();
+ if (pSceneManager == NULL)
+ {
+ return;
+ }
+ ArrayList* pArgList = new(std::nothrow) ArrayList();
+ if (pArgList == NULL)
+ {
+ return;
+ }
+ r = pArgList->Construct();
+ if (r == E_SUCCESS)
+ {
+ pArgList->Add(*pNewWindowInfo);
+ result r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
+ if (pArgList != null)
+ {
+ delete pArgList;
+ pArgList = null;
+ }
+ if(IsFailed(r))
+ {
+ AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
+ return;
+ }
+ }
+ __pConfirmationPopup->SetShowState(false);
+ __pConfirmationPopup->Show();
+
+ delete __pConfirmationPopup;
+ __pConfirmationPopup = null;
+
+ }
+ break;
+ default:
+ break;
+ }
+
+}
+
+void
+MultipleWindowForm::OnFormBackRequested(Form& source)
+{
+
+ String* pSelectedScene = NULL;
+ Object* value = NULL;
+
+ SceneManager* pSceneManager = SceneManager::GetInstance();
+ if (pSceneManager == null)
+ {
+ return;
+ }
+
+ MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &value);
+ pSelectedScene = (String*) value;
+ if (pSelectedScene != NULL)
+ {
+ result r = pSceneManager->GoBackward(BackwardSceneTransition(*pSelectedScene, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
+// delete pSelectedScene;
+ if(IsFailed(r))
+ {
+ AppLogDebug("MultipleWindowForm::OnFormBackRequested GoForward failed %s",GetErrorMessage(r));
+ return;
+ }
+ }
+ return;
+}
+
+void
+MultipleWindowForm::OnListViewContextItemStateChanged(ListView& listView, int index, int elementId, ListContextItemStatus state)
+{
+ return;
+}
+
+void
+MultipleWindowForm::OnListViewItemStateChanged(ListView& listView, int index, int elementId, ListItemStatus status)
+{
+ result r = E_SUCCESS;
+ ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
+ int count = 0;
+
+ if (elementId == IDA_FORMAT_DELETE_BITMAP)
+ {
+ // get current scene ID and check if it is matching with deleted scene id
+ WindowInfo* pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(index));
+ String* pSelectedScene = NULL;
+ Object* pValue = NULL;
+
+ if (pWindowInfo)
+ {
+ SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
+ MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
+ pSelectedScene = (String*) pValue;
+ pAllWindowList->RemoveAt(index, true);
+ if (pSelectedScene->CompareTo(pWindowInfo->sceneID) == 0)
+ {
+ //set current scene id to last scene id
+ int totalCount = pAllWindowList->GetCount() - 1;
+ WindowInfo* pLastIndexWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(totalCount));
+ if (pLastIndexWindowInfo != NULL)
+ {
+ String* pSelectedSceneID = new(std::nothrow) String(pLastIndexWindowInfo->sceneID);
+ if (pSelectedSceneID != NULL)
+ {
+ MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) pSelectedSceneID);
+
+ }
+ }
+ }
+ }
+
+ count = MultipleWindowPresentationModel::GetInstance()->GetInstance()->GetAllWindowArrayList()->GetCount();
+
+ if (count >= 9)
+ {
+ GetFooter()->SetItemEnabled(1,false);
+ }
+ else
+ {
+ GetFooter()->SetItemEnabled(1,true);
+ }
+
+ if ( count <= 1)
+ {
+ GetFooter()->SetItemEnabled(0,false);
+ }
+
+ GetFooter()->Invalidate(true);
+ __pList->RefreshList(index, LIST_REFRESH_TYPE_ITEM_REMOVE);
+ __pList->UpdateList();
+ }
+ else if(elementId == IDA_FORMAT_BITMAP || elementId == IDA_FORMAT_TITLE_STRING
+ || elementId == IDA_FORMAT_URL_STRING || elementId == -1)
+ {
+
+ // launch the browser
+ WindowInfo* pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(index));
+ if (pWindowInfo == NULL)
+ {
+ return;
+ }
+ SceneManager* pSceneManager = SceneManager::GetInstance();
+ if (pSceneManager == NULL)
+ {
+ return;
+ }
+ ArrayList* pArgList = new(std::nothrow) ArrayList();
+ if (pArgList == NULL)
+ {
+ return;
+ }
+ r = pArgList->Construct();
+ if (IsFailed(r))
+ {
+ return;
+ }
+ pArgList->Add(*pWindowInfo);
+ result r = pSceneManager->GoForward(ForwardSceneTransition(pWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
+
+ if (r == E_SUCCESS)
+ {
+ AppLogDebug("go forward success");
+ }
+ else
+ {
+ AppLogDebug("go forward failed");
+ }
+ if (pArgList != null)
+ {
+ delete pArgList;
+ pArgList = null;
+ }
+
+ }
+
+ return;
+}
+
+void
+MultipleWindowForm::OnListViewItemSwept(ListView& listView, int index, SweepDirection direction)
+{
+ return;
+}
+
+void
+MultipleWindowForm::OnListViewItemLongPressed(ListView& listView, int index, int elementId, bool& invokeListViewItemCallback)
+{
+ return;
+}
+
+ListItemBase*
+MultipleWindowForm::CreateItem(int index, int itemWidth)
+{
+ Rectangle listImageRect;
+ Rectangle pagetTitleRect;
+ Rectangle pageURLRect;
+ Rectangle deleteImageRect;
+ String pageTitle(L"");
+ String pageURL(L"");
+ result r = E_SUCCESS;
+ int width = W_ICON_IMAGE_WIDTH;
+
+ AppResource* pAppResource = Application::GetInstance()->GetAppResource();
+ ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
+ ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
+
+ if (pAllWindowList == null)
+ {
+ return null;
+ }
+ WindowInfo* pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(index));
+ if(pWindowInfo == null)
+ {
+ return NULL;
+ }
+ CustomItem* pItem = new(std::nothrow) CustomItem();
+ pageTitle = pWindowInfo->pageTitle;
+ pageURL = pWindowInfo->pageUrl;
+ if (pageURL.GetLength() == 0)
+ {
+ String nourl;
+ pAppResource->GetString(L"IDS_BR_BODY_BLANK_PAGE", nourl);
+ pageURL = L"<"+ nourl +">";
+ }
+
+ if (pageTitle.GetLength() == 0)
+ {
+ String nourl;
+ pAppResource->GetString(L"IDS_BR_BODY_BLANK_PAGE", pageTitle);
+ }
+
+ Rectangle screenBounds = GetBounds();
+ r = pItem->Construct(Dimension(itemWidth, 128 + (__fontSize - 44)), style);
+ if (IsFailed(r))
+ {
+ return NULL;
+ }
+
+ if (pWindowInfo->pFavicon)
+ {
+
+ if( __pListIconImage != NULL)
+ {
+ delete __pListIconImage;
+ __pListIconImage = null;
+ }
+
+ __pListIconImage = new Bitmap();
+ __pListIconImage->Construct(*(pWindowInfo->pFavicon),Rectangle(0,0,pWindowInfo->pFavicon->GetWidth(),pWindowInfo->pFavicon->GetHeight()));
+ }
+ else
+ {
+ if( __pListIconImage != NULL)
+ {
+ delete __pListIconImage;
+ __pListIconImage = null;
+ }
+
+ __pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
+ }
+
+
+ listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28 + (__fontSize - 44)/2,width, 72 );
+ pagetTitleRect.SetBounds(listImageRect.x + width + 16,10, screenBounds.width - 2 * width - 24 - 64, 72 + (__fontSize - 44));
+ pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * width - 120, 48);
+ if(__pListDeleteImage != null)
+ {
+ deleteImageRect.SetBounds(screenBounds.width - __pListDeleteImage->GetWidth() - 24, (128 + (__fontSize - 44) - __pListDeleteImage->GetHeight() - 8)/2, __pListDeleteImage->GetWidth() + 8, __pListDeleteImage->GetHeight() + 8);
+ }
+ pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *__pListIconImage, null, null);
+
+ if (pageTitle.CompareTo(L"") != 0)
+ {
+ pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, __fontSize, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
+ }
+
+ if (pageURL.CompareTo(L"") != 0)
+ {
+ pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_LISTVIEW_TEXT, CUSTOM_COLOR_LISTVIEW_TEXT, true);
+ }
+
+ if (pAllWindowList)
+ {
+ if (pAllWindowList->GetCount() > 1)
+ {
+ pItem->AddElement(deleteImageRect, IDA_FORMAT_DELETE_BITMAP, *__pListDeleteImage, null, null);
+ pItem->SetElementSelectionEnabled(IDA_FORMAT_DELETE_BITMAP, true);
+ }
+ }
+ return pItem;
+}
+
+bool
+MultipleWindowForm::DeleteItem(int index, ListItemBase* pItem, int itemWidth)
+{
+ delete pItem;
+ pItem = null;
+ return true;
+}
+
+int
+MultipleWindowForm::GetItemCount(void)
+{
+ ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
+ int windowCount = 0;
+
+ if (pAllWindowList != null)
+ {
+ windowCount = pAllWindowList->GetCount();
+ }
+ if (windowCount < 2)
+ {
+ GetFooter()->SetItemEnabled(0, false);
+ }
+ else
+ {
+ GetFooter()->SetItemEnabled(0, true);
+ }
+ GetFooter()->Invalidate(true);
+ return windowCount;
+}
+
+void
+MultipleWindowForm::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus)
+{
+ if (__pList)
+ {
+ __pList->UpdateList();
+ }
+}
+
+void
+MultipleWindowForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
+{
+ AppLog("receiving userevent for appcontrol %d",requestId);
+ if (requestId == APPCONTROL_LAUNCH_MAX_LIMIT_REACHED)
+ {
+ AppLog("receiving userevent for appcontrol %d ",requestId);
+ if(__pConfirmationPopup)
+ {
+ __pConfirmationPopup->SetShowState(false);
+ delete __pConfirmationPopup;
+ __pConfirmationPopup = null;
+ }
+ }
+}