modification of formdatawindow fix for N_SE-43749
authorBINDUCHAITANYA TUMMALA <bc.tummala@samsung.com>
Tue, 2 Jul 2013 14:16:43 +0000 (19:46 +0530)
committerBINDUCHAITANYA TUMMALA <bc.tummala@samsung.com>
Wed, 3 Jul 2013 07:39:07 +0000 (13:09 +0530)
Change-Id: Ibd3e114f278d2d88a4255e761b753325c271aa58
Signed-off-by: BINDUCHAITANYA TUMMALA <bc.tummala@samsung.com>
src/controls/FWebCtrl_FormDataWindow.cpp
src/controls/FWebCtrl_FormDataWindow.h

index cb8c5fd..bea08c0 100644 (file)
@@ -45,9 +45,6 @@ namespace Tizen { namespace Web { namespace Controls
 {
 
 
-static const int MAX_LIST_ITEM_COUNT = 3;
-
-
 _FormDataWindow::_FormDataWindow(void)
                                        : __pListView(null)
                                        , __pWebView(null)
@@ -71,9 +68,12 @@ _FormDataWindow::Construct(const Rectangle& rect, _WebImpl* pImpl, Evas_Object*
        result r = layout.Construct(VERTICAL_DIRECTION_DOWNWARD);
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
-       GET_SHAPE_CONFIG(CONTEXTMENU::LIST_ITEM_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __listItemHeight);
+       GET_COLOR_CONFIG(LIST::ELEMENT_TEXT_NORMAL, __normalColor);
+       GET_COLOR_CONFIG(LIST::ELEMENT_TEXT_PRESSED, __pressedColor);
+       GET_COLOR_CONFIG(LIST::ELEMENT_TEXT_HIGHLIGHTED, __highlightedColor);
+
+       __listItemHeight = rect.height;
        Rectangle windowRect(rect);
-       windowRect.height = MAX_LIST_ITEM_COUNT*__listItemHeight;
 
        r = Window::Construct(layout, windowRect, true, true);
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Error Propogating.", GetErrorMessage(r));
@@ -125,7 +125,26 @@ _FormDataWindow::CreateItem(int index, int itemWidth)
        result r = pItem->Construct(Dimension(itemWidth, __listItemHeight), LIST_ANNEX_STYLE_NORMAL);
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
 
-       r = pItem->AddElement(Rectangle(0, 0, itemWidth, __listItemHeight), ID_FORMAT_STRING, *pListElement, true);
+       int listItemHeight = 0;
+       int listItemTextSize = 0;
+       int listItemLeftMargin = 0;
+
+       GET_SHAPE_CONFIG(LIST::LIST_DEFAULT_ITEM_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, listItemHeight);
+       GET_SHAPE_CONFIG(LIST::LIST_ITEM_TEXT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, listItemTextSize);
+       GET_SHAPE_CONFIG(LIST::LIST_ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, listItemLeftMargin);
+
+       if (__listItemHeight > listItemHeight)
+       {
+               __listItemHeight = listItemHeight;
+       }
+
+       if (__listItemHeight*2/3 < listItemTextSize)
+       {
+               listItemTextSize = __listItemHeight*2/3;
+       }
+
+       Rectangle itemRect = Rectangle(listItemLeftMargin, 0, itemWidth, __listItemHeight);
+       r = pItem->AddElement(itemRect, ID_FORMAT_STRING, *pListElement, listItemTextSize, __normalColor, __pressedColor, __highlightedColor);
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
 
        return pItem.release();
@@ -187,6 +206,8 @@ _FormDataWindow::UpdateList(Eina_List* pDataList, const Rectangle& rect)
 
        __listElementArray.RemoveAll(true);
 
+       __listItemHeight = rect.height;
+
        int itemCount = eina_list_count(pDataList);
 
        for (int itemIndex = 0; itemIndex < itemCount; itemIndex++)
@@ -204,9 +225,54 @@ _FormDataWindow::UpdateList(Eina_List* pDataList, const Rectangle& rect)
 
        __pListView->UpdateList();
 
-       Rectangle rec(rect);
-       rec.height = (itemCount >= MAX_LIST_ITEM_COUNT) ? (MAX_LIST_ITEM_COUNT*__listItemHeight) : (itemCount*__listItemHeight);
-       SetBounds(rec);
+       int windowHeight = itemCount*__listItemHeight;
+
+       Rectangle webRect = __pWebImpl->GetBounds();//is it better to take application rect
+       int bottomLimit = webRect.y + webRect.height;
+       int topLimit = webRect.y;
+       Rectangle windowRect(rect);
+
+       if (__pWebImpl->IsKeypadVisible())
+       {
+               Rectangle keyRect = __pWebImpl->GetPreviousKeypadBounds();
+               bottomLimit = keyRect.y;
+       }
+
+       int windowBottom = rect.y + windowHeight;
+
+       while (true)
+       {
+               if (windowBottom > bottomLimit)
+               {
+                       int newWindowTop = rect.y - rect.height - windowHeight;
+                       if (newWindowTop < topLimit)//check in reverse direction
+                       {
+                               if (--itemCount)
+                               {
+                                       windowHeight = itemCount*__listItemHeight;
+                                       windowBottom = rect.y + windowHeight;
+                               }
+                               else
+                               {
+                                       break;
+                               }
+                       }
+                       else
+                       {//reverse direction is good
+                               windowRect.y = rect.y - rect.height - windowHeight;
+                               break;
+                       }
+               }
+               else
+               {
+                       //rect is good
+                       break;
+               }
+       }
+
+       windowRect.height = windowHeight;
+       __pListView->SetBounds(Rectangle(0, 0, windowRect.width, windowRect.height));
+       SetBounds(windowRect);
 
        return E_SUCCESS;
 }
index 9e22941..d422536 100644 (file)
@@ -103,6 +103,7 @@ private:
        Evas_Object* __pWebView;
        _WebImpl* __pWebImpl;
        int __listItemHeight;
+       Tizen::Graphics::Color __normalColor, __pressedColor, __highlightedColor;
 }; // _FormDataWindow
 
 }}} //Tizen::Web::Controls