X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2FIntMultipleWindowForm.cpp;h=b95ae847b811fc5688cd634ffac966c9b23d2d4a;hb=96da7857a864d334ef77c84db963a7bdaabe8de2;hp=e5c5d642c1dcd628aa86e7546645e51b7b79b159;hpb=324d5cb2fb4cbdf85e040dc87e6702c8f4412b26;p=apps%2Fosp%2FInternet.git diff --git a/src/IntMultipleWindowForm.cpp b/src/IntMultipleWindowForm.cpp index e5c5d64..b95ae84 100644 --- a/src/IntMultipleWindowForm.cpp +++ b/src/IntMultipleWindowForm.cpp @@ -1,612 +1,657 @@ -// -// Copyright (c) 2012 Samsung Electronics Co., Ltd. -// -// Licensed under the Flora License, Version 1.0 (the License); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://floralicense.org/license/ -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an AS IS BASIS, -// WITHOUT 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 -#include - -#include "IntCommonLib.h" -#include "IntConfirmationPopup.h" -#include "IntMainForm.h" -#include "IntMultipleWindowForm.h" -#include "IntMultipleWindowPresentationModel.h" -#include "IntSceneRegister.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) -{ -} - -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; - - 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_CLOSE_ALL")); - r = pFooter->AddItem(closeButton); - r = newButton.Construct(IDA_BUTTON_NEW); - r = newButton.SetText(CommonUtil::GetString(L"IDS_BR_SK1_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_CLOSE_ALL_WINDOWS_Q"); - - switch (actionId) - { - case IDA_BUTTON_NEW: - { - WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene(); - - 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: - { - __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(); - } - 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); - WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene(); - - 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; - } - 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(); - } - 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_ABOUT_C_BLANK", nourl); - pageURL = L"<"+ nourl +">"; - } - - Rectangle screenBounds = GetBounds(); - r = pItem->Construct(Dimension(itemWidth, 128), 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"); - } - AppLog("deleteimg %d %d",__pListDeleteImage->GetWidth(),__pListDeleteImage->GetHeight()); - - listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28,width, 72); - pagetTitleRect.SetBounds(listImageRect.x + width + 16,10, screenBounds.width - 2 * width - 64, 60); - pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * width - 120, 48); - deleteImageRect.SetBounds(screenBounds.width - __pListDeleteImage->GetWidth() - 24, (128 - __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, 44, 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_GREY, CUSTOM_COLOR_GREY, 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(); - } -} +// +// 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 +#include + +#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_GREY, CUSTOM_COLOR_GREY, 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(); + } +}