#include "FUi_AccessibilityContainer.h"
#include "FUi_AccessibilityElement.h"
#include "FUi_AccessibilityManager.h"
+#include "FUi_CoordinateSystemUtils.h"
using namespace Tizen::Graphics;
using namespace Tizen::Ui;
{
__color[i] = Color(0);
__textColor[i] = Color(0);
+ __guideTextColor[i] = Color(0);
}
_AccessibilityContainer* pContainer = GetAccessibilityContainer();
// Setting Button color
GET_COLOR_CONFIG(SEARCHBAR::BUTTON_BG_NORMAL, __buttonColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
- GET_COLOR_CONFIG(SEARCHBAR::BUTTON_PRESSED, __buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
- GET_COLOR_CONFIG(SEARCHBAR::BUTTON_HIGHLIGHTED, __buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
- GET_COLOR_CONFIG(SEARCHBAR::BUTTON_DISABLED, __buttonColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
+ GET_COLOR_CONFIG(SEARCHBAR::BUTTON_BG_PRESSED, __buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
+ GET_COLOR_CONFIG(SEARCHBAR::BUTTON_BG_HIGHLIGHTED, __buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
+ GET_COLOR_CONFIG(SEARCHBAR::BUTTON_BG_DISABLED, __buttonColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_NORMAL, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_PRESSED, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
{
case SEARCH_FIELD_STATUS_DISABLED:
GET_COLOR_CONFIG(SEARCHBAR::EDIT_BG_DISABLED, __color[i]);
- GET_COLOR_CONFIG(SEARCHBAR::EDIT_TEXT_DISABLED, __textColor[i]);
+ GET_COLOR_CONFIG(SEARCHBAR::GUIDE_TEXT_DISABLED, __guideTextColor[i]);
break;
case SEARCH_FIELD_STATUS_HIGHLIGHTED:
GET_COLOR_CONFIG(SEARCHBAR::EDIT_BG_NORMAL, __color[i]);
- GET_COLOR_CONFIG(SEARCHBAR::EDIT_TEXT_HIGHLIGHTED, __textColor[i]);
+ GET_COLOR_CONFIG(SEARCHBAR::GUIDE_TEXT_HIGHLIGHTED, __guideTextColor[i]);
break;
default:
GET_COLOR_CONFIG(SEARCHBAR::EDIT_BG_NORMAL, __color[i]);
- GET_COLOR_CONFIG(SEARCHBAR::EDIT_TEXT_NORMAL, __textColor[i]);
+ GET_COLOR_CONFIG(SEARCHBAR::GUIDE_TEXT_NORMAL, __guideTextColor[i]);
break;
}
}
{
result r = E_SUCCESS;
- Rectangle editBounds;
+ FloatRectangle editBounds;
int horizontalMargin = 0;
int verticalMargin = 0;
int iconHorizontalMargin = 0;
int iconWidth = 0;
int textSize = 0;
int searchFieldMinWidth = 0;
- int searchFieldMinHeight = 0;
+ int searchBarMinHeight = 0;
- Rectangle searchBarBounds = GetBounds();
+ FloatRectangle searchBarBounds = GetBoundsF();
_ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
_AccessibilityContainer* pSearchBarContainer = null;
GET_SHAPE_CONFIG(SEARCHBAR::ICON_WIDTH, orientation, iconWidth);
GET_SHAPE_CONFIG(SEARCHBAR::TEXT_HORIZONTAL_MARGIN, orientation, textHorizontalMargin);
GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH, orientation, searchFieldMinWidth);
- GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_HEIGHT, orientation, searchFieldMinHeight);
+ GET_SHAPE_CONFIG(SEARCHBAR::MIN_HEIGHT, orientation, searchBarMinHeight);
- editBounds.x = horizontalMargin;
- editBounds.y = verticalMargin;
- editBounds.width = searchBarBounds.width - (editBounds.x * 2);
- editBounds.height = searchBarBounds.height - (editBounds.y * 2);
+ int searchFieldMinHeight = searchBarMinHeight - (verticalMargin * 2);
+
+ editBounds.x = _CoordinateSystemUtils::ConvertToFloat(horizontalMargin);
+ editBounds.y = _CoordinateSystemUtils::ConvertToFloat(verticalMargin);
+ editBounds.width = searchBarBounds.width - (editBounds.x * 2.0f);
+ editBounds.height = searchBarBounds.height - (editBounds.y * 2.0f);
editBounds.width = (editBounds.width > searchFieldMinWidth) ? editBounds.width : searchFieldMinWidth;
editBounds.height = (editBounds.height > searchFieldMinHeight) ? editBounds.height : searchFieldMinHeight;
__pEdit->SetKeypadCommandButtonVisible(false);
__pEdit->SetBounds(editBounds);
-
__pEdit->AddKeypadEventListener(*this);
__pEdit->AddTextBlockEventListener(*this);
__pEdit->AddTextEventListener(*this);
__pEdit->SetColor(editStatus, __color[status]);
}
- __pEdit->SetTextColor(EDIT_TEXT_COLOR_NORMAL, __textColor[SEARCH_FIELD_STATUS_NORMAL]);
- __pEdit->SetTextColor(EDIT_TEXT_COLOR_DISABLED, __textColor[SEARCH_FIELD_STATUS_DISABLED]);
- __pEdit->SetTextColor(EDIT_TEXT_COLOR_HIGHLIGHTED, __textColor[SEARCH_FIELD_STATUS_HIGHLIGHTED]);
-
__pEdit->ReplaceDefaultBackgroundBitmapForSearchBar();
+ __pEdit->SetPressedGuideTextColor(__guideTextColor[SEARCH_FIELD_STATUS_HIGHLIGHTED]);
__pEdit->SetKeypadAction(__keypadAction);
SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM,
"[E_SYSTEM] A system error has occurred. Failed to attach edit as child.");
- if(likely(!(_AccessibilityManager::IsActivated())))
+ if (likely(!(_AccessibilityManager::IsActivated())))
{
return E_SUCCESS;
}
SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM,
"[E_SYSTEM] A system error has occurred. Failed to attach button as child.");
- if(likely(!(_AccessibilityManager::IsActivated())))
+ if (likely(!(_AccessibilityManager::IsActivated())))
{
return E_SUCCESS;
}
return;
}
- Dimension screenSize = _ControlManager::GetInstance()->GetScreenSize();
- int width = screenSize.width;
- int height = screenSize.height;
+ FloatDimension screenSize = _ControlManager::GetInstance()->GetScreenSizeF();
+ float width = screenSize.width;
+ float height = screenSize.height;
+
_Control* pParent = GetParentForm();
if (pParent != null)
{
- width = pParent->GetClientBounds().width;
- height = pParent->GetClientBounds().height;
+ width = pParent->GetClientBoundsF().width;
+ height = pParent->GetClientBoundsF().height;
}
- __contentAreaBounds = GetBounds();
- __contentAreaBounds.x = 0;
+ __contentAreaBounds = GetBoundsF();
+ __contentAreaBounds.x = 0.0f;
__contentAreaBounds.y = __contentAreaBounds.height;
__contentAreaBounds.width = width;
__contentAreaBounds.height = height - __contentAreaBounds.height;
result r = E_SUCCESS;
r = __pContainer->SetBounds(__contentAreaBounds);
SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
-
- if (pParent)
- {
- _Form* pForm = dynamic_cast<_Form*>(pParent);
- if (pForm)
- {
- pForm->Invalidate(true);
- }
- }
}
return;
}
int limitLength = __pEdit->GetTextLimitLength();
int textLength = text.GetLength();
- SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_MAX_EXCEEDED, E_MAX_EXCEEDED,
- "[E_MAX_EXCEEDED] limitLength(%d) exceeds the maximum limit textLength(%d).", limitLength, textLength);
+ SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_SYSTEM, E_SYSTEM,
+ "[E_SYSTEM] A system error has occurred. textLength exceeds the limitLength");
r = __pEdit->SetText(text);
SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
limitLength = __pEdit->GetTextLimitLength();
textLength = __pEdit->GetTextLength() + 1;
- SysTryReturn(NID_UI_CTRL, limitLength > textLength, E_MAX_EXCEEDED, E_MAX_EXCEEDED,
+ SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_MAX_EXCEEDED, E_MAX_EXCEEDED,
"[E_MAX_EXCEEDED] limitLength(%d) exceeds the maximum limit textLength(%d).", limitLength, textLength);
- SysTryReturn(NID_UI_CTRL, textLength >= index, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
- "[E_OUT_OF_RANGE] index(%d) is out of range textLength(%d).", index, textLength);
+ SysTryReturn(NID_UI_CTRL, index <= __pEdit->GetTextLength(), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
+ "[E_OUT_OF_RANGE] index(%d) is out of range of current textLength(%d).", index, __pEdit->GetTextLength());
r = __pEdit->InsertCharacterAt(index, character);
SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
SysTryReturn(NID_UI_CTRL, index > -1, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
"[E_OUT_OF_RANGE] index(%d) is out of range.", index);
+ result r = E_SUCCESS;
+
int textLength = 0;
int limitLength = 0;
limitLength = __pEdit->GetTextLimitLength();
textLength = __pEdit->GetTextLength() + text.GetLength();
- SysTryReturn(NID_UI_CTRL, limitLength > textLength, E_MAX_EXCEEDED, E_MAX_EXCEEDED,
+ SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_MAX_EXCEEDED, E_MAX_EXCEEDED,
"[E_MAX_EXCEEDED] limitLength(%d) exceeds the maximum limit textLength(%d).", limitLength, textLength);
- SysTryReturn(NID_UI_CTRL, textLength >= index, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
- "[E_OUT_OF_RANGE] index(%d) is out of range textLength(%d).", index, textLength);
+ SysTryReturn(NID_UI_CTRL, index <= __pEdit->GetTextLength(), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
+ "[E_OUT_OF_RANGE] index(%d) is out of range of current textLength(%d).", index, __pEdit->GetTextLength());
- return __pEdit->InsertTextAt(index, text);
+ r = __pEdit->InsertTextAt(index, text);
+ SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
+ "[E_SYSTEM] A system error has occurred. Failed to insert text.");
+
+ return r;
}
result
SysTryReturn(NID_UI_CTRL, index > -1, E_INVALID_ARG, E_INVALID_ARG,
"[E_INVALID_ARG] Invalid argument(s) is used. index = %d", index);
+ result r = E_SUCCESS;
int textLength = 0;
textLength = __pEdit->GetTextLength();
SysTryReturn(NID_UI_CTRL, textLength > index, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
"[E_OUT_OF_RANGE] index(%d) is out of range. textLength(%d)", index, textLength);
- return __pEdit->DeleteCharacterAt(index);
+ r = __pEdit->DeleteCharacterAt(index);
+ SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM,
+ "[E_SYSTEM] A system error has occured. Failed to delete character.");
+
+ return r;
}
result
return r;
}
-int
-_SearchBar::GetSearchFieldTextSize(void) const
+float
+_SearchBar::GetSearchFieldTextSizeF(void) const
{
SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM,
"[E_SYSTEM] A system error has occurred. The edit instance is null.");
- return __pEdit->GetTextSize();
+ return __pEdit->GetTextSizeF();
}
result
-_SearchBar::SetSearchFieldTextSize(int size)
+_SearchBar::SetSearchFieldTextSize(float size)
{
SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
"[E_SYSTEM] A system error has occurred. The edit instance is null.");
int endIndex = -1;
__pEdit->GetBlockRange(startIndex, endIndex);
- SysTryReturn(NID_UI_CTRL, (startIndex > -1 && endIndex > -1), E_SYSTEM, E_SYSTEM,
+ SysTryReturn(NID_UI_CTRL, (startIndex > -1 && endIndex > 0), E_SYSTEM, E_SYSTEM,
"[E_SYSTEM] A system error has occurred. Failed to get text block range.");
start = startIndex;
- end = endIndex;
+ end = endIndex - 1;
return E_SUCCESS;
}
int textLength = 0;
textLength = __pEdit->GetTextLength();
- SysTryReturn(NID_UI_CTRL, (textLength > start && textLength > end), E_INVALID_ARG, E_INVALID_ARG,
- "[E_INVALID_ARG] Invalid argument(s) is used. textLength = %d, start = %d, end = %d", start, end);
- SysTryReturn(NID_UI_CTRL, (start <= end && start >= 0), E_INVALID_ARG, E_INVALID_ARG,
- "[E_INVALID_ARG] Invalid argument(s) is used. start = %d, end = %d", start, end);
+
+ SysTryReturn(NID_UI_CTRL, (start < end && start >= 0 && textLength >= end), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
+ "[E_OUT_OF_RANGE] start (%d) and end (%d) is out of range.", start, end - 1);
r = SetCursorPosition(start);
SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
result r = E_SUCCESS;
- int start = 0;
- int end = 0;
-
- r = GetBlockRange(start, end);
+ r = __pEdit->RemoveTextBlock();
SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
- for (int index = start; index < end; index++)
- {
- r = __pEdit->DeleteCharacterAt(start);
- SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
- }
-
return r;
}
EllipsisPosition
_SearchBar::GetEllipsisPosition(void) const
{
- SysTryReturn(NID_UI_CTRL, __pEdit, ELLIPSIS_POSITION_START, ELLIPSIS_POSITION_START,
+ SysTryReturn(NID_UI_CTRL, __pEdit, ELLIPSIS_POSITION_START, E_SYSTEM,
"[E_SYSTEM] A system error has occurred. The edit instance is null.");
return __pEdit->GetEllipsisPosition();
}
void
+_SearchBar::OnChangeLayout(_ControlOrientation orientation)
+{
+ SetContentsArea();
+}
+
+void
_SearchBar::OnDraw(void)
{
+ SearchFieldStatus searchFieldStatus = GetCurrentStatus();
+ SetGuideTextColor(__guideTextColor[searchFieldStatus]);
+
__pSearchBarPresenter->Draw();
return;
}
__pKeypadEvent->Fire(*pEventArg);
}
+
+ SetContentsArea();
return;
}
__pKeypadEvent->Fire(*pEventArg);
}
+
+ SetContentsArea();
return;
}
return false;
}
+bool
+_SearchBar::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
+{
+ if (!__pEdit->IsUsbKeyboardConnected())
+ {
+ return false;
+ }
+
+ _KeyCode keyCode = keyInfo.GetKeyCode();
+
+ if (keyCode == _KEY_RIGHT)
+ {
+ if (__isButtonEnabled)
+ {
+ __pEdit->SetFocused(false);
+ __pCancelButton->SetButtonStatus(_BUTTON_STATUS_HIGHLIGHTED);
+ __pCancelButton->SetFocused();
+ __pCancelButton->Invalidate(true);
+ }
+
+ return true;
+ }
+
+ if (keyCode == _KEY_LEFT)
+ {
+ if (__pCancelButton->GetButtonStatus() == _BUTTON_STATUS_HIGHLIGHTED)
+ {
+ __pCancelButton->SetButtonStatus(_BUTTON_STATUS_NORMAL);
+ __pCancelButton->SetFocused(false);
+ __pCancelButton->Invalidate();
+
+ }
+
+ if (__pCancelButton->GetButtonStatus() == _BUTTON_STATUS_DISABLED) //Searchbar Button is disabled, left arrow key is pressed
+ {
+ __pCancelButton->SetButtonStatus(_BUTTON_STATUS_NORMAL);
+ SetButtonEnabled(false);
+ }
+
+ __pEdit->SetFocused();
+
+ return true;
+ }
+
+ return false;
+}
+
+bool
+_SearchBar::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
+{
+ return false;
+}
+
_Control*
_SearchBar::GetParentForm(void) const
{
result
_SearchBar::SetPropertyContentAreaSize(const Variant& size)
{
- Dimension contentAreaSize = size.ToDimension();
+ FloatDimension contentAreaSize = size.ToFloatDimension();
SysTryReturn(NID_UI_CTRL, contentAreaSize.width >= 0 && contentAreaSize.height >= 0, E_INVALID_ARG, E_INVALID_ARG,
- "[E_INVALID_ARG] Invalid argument(s) is used. contentAreaSize.width = %d, contenAreaSize.height = %d",
+ "[E_INVALID_ARG] Invalid argument(s) is used. contentAreaSize.width = %f, contenAreaSize.height = %f",
contentAreaSize.width, contentAreaSize.height);
result r = E_SUCCESS;
// Todo
- Rectangle bounds = GetBounds();
- Rectangle contentAreaBounds(0, 0, 0, 0);
+ FloatRectangle bounds = GetBoundsF();
+ FloatRectangle contentAreaBounds(0.0f, 0.0f, 0.0f, 0.0f);
- contentAreaBounds.x = 0;
+ contentAreaBounds.x = 0.0f;
contentAreaBounds.y = bounds.height;
contentAreaBounds.width = contentAreaSize.width;
contentAreaBounds.height = contentAreaSize.height;
Variant
_SearchBar::GetPropertyContentAreaSize(void) const
{
- Dimension contentAreaSize(__contentAreaBounds.width, __contentAreaBounds.height);
+ FloatDimension contentAreaSize(__contentAreaBounds.width, __contentAreaBounds.height);
return Variant(contentAreaSize);
}
_SearchBar::CreateClippedGroupControl(void)
{
result r = E_SUCCESS;
- Rectangle clippedGroupControlBounds(Point(0, 0), GetSize());
-
+ FloatRectangle clippedGroupControlBounds(FloatPoint(0.0f, 0.0f), GetSizeF());
__pClippedGroupControl = _Control::CreateControlN();
r = GetLastResult();
SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
void
_SearchBar::SetContentDimming(void)
{
- if(__pContainer != NULL)
+ if (__pContainer != NULL)
{
if (!GetTextLength())
{
int buttonRightMargin = 0;
int buttonMinWidth = 0;
int searchFieldMinWidth = 0;
+ int buttonVerticalMargin = 0;
+ int searchBarMinHeight = 0;
+ int buttonWidth = 0;
+ int buttonHeight = 0;
- Rectangle cancelButtonBounds;
- Rectangle searchBarBounds = GetBounds();
+ FloatRectangle cancelButtonBounds;
+ FloatRectangle searchBarBounds = GetBoundsF();
_ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
GET_SHAPE_CONFIG(SEARCHBAR::HORIZONTAL_MARGIN, orientation, horizontalMargin);
GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_LEFT_MARGIN, orientation, buttonLeftMargin);
GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_RIGHT_MARGIN, orientation, buttonRightMargin);
- GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_WIDTH, orientation, cancelButtonBounds.width);
- GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_HEIGHT, orientation, cancelButtonBounds.height);
+ GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_WIDTH, orientation, buttonWidth);
+ GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_HEIGHT, orientation, buttonHeight);
GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_MIN_WIDTH, orientation, buttonMinWidth);
GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH, orientation, searchFieldMinWidth);
+ GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, buttonVerticalMargin);
+ GET_SHAPE_CONFIG(SEARCHBAR::MIN_HEIGHT, orientation, searchBarMinHeight);
+
+ cancelButtonBounds.width = _CoordinateSystemUtils::ConvertToFloat(buttonWidth);
+ cancelButtonBounds.height = _CoordinateSystemUtils::ConvertToFloat(buttonHeight);
- int buttonResizableSearchBarWidth = (horizontalMargin + searchFieldMinWidth +
+ float buttonResizableSearchBarWidth = (horizontalMargin + searchFieldMinWidth +
cancelButtonBounds.width + buttonLeftMargin + buttonRightMargin);
- if(searchBarBounds.width < buttonResizableSearchBarWidth)
+ if (searchBarBounds.width < buttonResizableSearchBarWidth)
{
cancelButtonBounds.width = searchBarBounds.width -(searchFieldMinWidth + buttonLeftMargin
+ buttonRightMargin + horizontalMargin);
}
cancelButtonBounds.x = searchBarBounds.width - cancelButtonBounds.width - buttonRightMargin;
- cancelButtonBounds.y = (searchBarBounds.height - cancelButtonBounds.height)/2;
+ cancelButtonBounds.y = (searchBarBounds.height - cancelButtonBounds.height)/2.0f;
+ if (searchBarBounds.height < searchBarMinHeight)
+ {
+ cancelButtonBounds.y = buttonVerticalMargin;
+ }
- if(cancelButtonBounds.width < buttonMinWidth)
+ if (cancelButtonBounds.width < buttonMinWidth)
{
cancelButtonBounds.width = buttonMinWidth;
}
- cancelButtonBounds.width = (cancelButtonBounds.width > 0) ? cancelButtonBounds.width : 0;
- cancelButtonBounds.height = (cancelButtonBounds.height > 0) ? cancelButtonBounds.height : 0;
-
+ cancelButtonBounds.width = (cancelButtonBounds.width > 0.0f) ? cancelButtonBounds.width : 0.0f;
+ cancelButtonBounds.height = (cancelButtonBounds.height > 0.0f) ? cancelButtonBounds.height : 0.0f;
r = __pCancelButton->SetBounds(cancelButtonBounds);
return r;
}
+void
+_SearchBar::RecalculateButtonBounds(void)
+{
+ result r = E_SUCCESS;
+
+ Float horizontalMargin = 0;
+ Float verticalMargin = 0;
+ Float buttonLeftMargin = 0;
+ Float buttonRightMargin = 0;
+ Float buttonMinWidth = 0;
+ Float searchFieldMinWidth = 0;
+ Float buttonVerticalMargin = 0;
+ Float searchBarMinHeight = 0;
+ Float buttonWidth = 0;
+ Float buttonHeight = 0;
+
+ FloatRectangle cancelButtonBounds;
+ FloatRectangle searchBarBounds = GetBoundsF();
+
+ _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
+
+ GET_SHAPE_CONFIG(SEARCHBAR::HORIZONTAL_MARGIN, orientation, horizontalMargin);
+ GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, verticalMargin);
+ GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_LEFT_MARGIN, orientation, buttonLeftMargin);
+ GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_RIGHT_MARGIN, orientation, buttonRightMargin);
+ GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_WIDTH, orientation, buttonWidth);
+ GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_HEIGHT, orientation, buttonHeight);
+ GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_MIN_WIDTH, orientation, buttonMinWidth);
+ GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH, orientation, searchFieldMinWidth);
+ GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, buttonVerticalMargin);
+ GET_SHAPE_CONFIG(SEARCHBAR::MIN_HEIGHT, orientation, searchBarMinHeight);
+
+ cancelButtonBounds.height = buttonHeight ;
+
+ FloatRectangle editBounds;
+
+ float cancelButtonWidth = 0;
+ cancelButtonWidth = __pCancelButton->GetTextExtentSizeF() + __pCancelButton->GetRightTouchMarginF() + __pCancelButton->GetLeftTouchMarginF() + __pCancelButton->GetRightMarginF() + __pCancelButton->GetLeftMarginF();
+ editBounds.x = horizontalMargin;
+ editBounds.y = verticalMargin;
+
+ editBounds.height = searchBarBounds.height - (editBounds.y * 2.0f);
+ editBounds.height = (editBounds.height > searchBarMinHeight) ? editBounds.height : searchBarMinHeight;
+
+ editBounds.width = searchBarBounds.width - cancelButtonWidth - (2 * horizontalMargin) - buttonLeftMargin;
+
+ if (editBounds.width < searchFieldMinWidth)
+ {
+ editBounds.width = searchFieldMinWidth;
+ }
+
+ cancelButtonBounds.x = editBounds.width + horizontalMargin + buttonLeftMargin;
+ cancelButtonBounds.y = (searchBarBounds.height - cancelButtonBounds.height)/2.0f;
+
+ if (searchBarBounds.height < searchBarMinHeight)
+ {
+ cancelButtonBounds.y = buttonVerticalMargin;
+ }
+
+ if (cancelButtonWidth < buttonMinWidth)
+ {
+ cancelButtonBounds.width = buttonMinWidth;
+ }
+ else
+ {
+ cancelButtonBounds.width = searchBarBounds.width - cancelButtonBounds.x - buttonRightMargin;
+ }
+
+ cancelButtonBounds.width = (cancelButtonBounds.width > 0.0f) ? cancelButtonBounds.width : 0.0f;
+ cancelButtonBounds.height = (cancelButtonBounds.height > 0.0f) ? cancelButtonBounds.height : 0.0f;
+
+ r = __pCancelButton->SetBounds(cancelButtonBounds);
+ SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+ r = __pEdit->SetBounds(editBounds);
+ SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ return;
+}
+
+SearchFieldStatus
+_SearchBar::GetCurrentStatus(void)
+{
+ SearchFieldStatus searchFieldStatus = SEARCH_FIELD_STATUS_NORMAL;
+
+ if (IsEnabled())
+ {
+ if (__pEdit->IsFocused())
+ {
+ searchFieldStatus = SEARCH_FIELD_STATUS_HIGHLIGHTED;
+ }
+ }
+ else
+ {
+ searchFieldStatus = SEARCH_FIELD_STATUS_DISABLED;
+ }
+
+ return searchFieldStatus;
+}
+
+void
+_SearchBar::SetEditTextFilter(IEditTextFilter* pFilter)
+{
+ SysTryReturnVoidResult(NID_UI_CTRL, __pEdit, E_SYSTEM,
+ "[E_SYSTEM] A system error has occurred. The edit instance is null.");
+
+ __pEdit->SetEditTextFilter(pFilter);
+
+ return;
+}
+
+void
+_SearchBar::SendOpaqueCommand(const String& command)
+{
+ SysTryReturnVoidResult(NID_UI_CTRL, __pEdit, E_SYSTEM,
+ "[E_SYSTEM] A system error has occurred. The edit instance is null.");
+
+ __pEdit->SendOpaqueCommand(command);
+
+ return;
+}
+
}}} // Tizen::Ui::Controls