// http://www.apache.org/licenses/LICENSE-2.0/
//
// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an ”AS IS” BASIS,
+// 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.
#include "FUi_AccessibilityElement.h"
#include "FUi_AccessibilityManager.h"
#include "FUi_CoordinateSystemUtils.h"
+#include "FUiCtrl_SearchBarImpl.h"
+#include "FUiCtrl_EditFieldImpl.h"
+#include "FUiCtrl_ButtonImpl.h"
+#include <FSys_SettingInfoImpl.h>
+
using namespace Tizen::Graphics;
using namespace Tizen::Ui;
using namespace Tizen::Base;
using namespace Tizen::Base::Runtime;
using namespace Tizen::Locales;
+using namespace Tizen::System;
namespace Tizen { namespace Ui { namespace Controls
{
, __isUserGuideTextColor(false)
, __isKeypadOpening(false)
, __isupdateContentBounds(false)
+ , __isKeyPressed(false)
+ , __isFocusCallbackToBeFired(true)
+ , __isButtonTextChangedByApp(false)
, __keypadAction(CORE_KEYPAD_ACTION_SEARCH)
, __pBackgroundBitmap(null)
, __backgroundColor(Color())
_SearchBar::~_SearchBar(void)
{
+ SettingInfo::RemoveSettingEventListener(*this);
delete __pSearchBarPresenter;
__pSearchBarPresenter = null;
- if (__pEdit)
- {
- __pEdit->HideKeypad();
-
- __pClippedGroupControl->DetachChild(*__pEdit);
-
- delete __pEdit;
- __pEdit = null;
- }
-
- if (__pCancelButton)
- {
- __pClippedGroupControl->DetachChild(*__pCancelButton);
-
- delete __pCancelButton;
- __pCancelButton = null;
- }
-
if (__pClippedGroupControl)
{
DetachChild(*__pClippedGroupControl);
__pSearchBarPresenter = pPresenter;
CreateAccessibilityElement();
+
+ r = _SettingInfoImpl::AddSettingEventListener(*this);
+ SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
return r;
CATCH:
editBounds.width = (editBounds.width > searchBarMinWidthModeNormal) ? editBounds.width : searchBarMinWidthModeNormal;
editBounds.height = (editBounds.height > searchFieldMinHeight) ? editBounds.height : searchFieldMinHeight;
- __pEdit = _Edit::CreateEditN();
- r = GetLastResult();
- SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
+ _SearchBarImpl* pSearchBarImpl = static_cast<_SearchBarImpl*>(GetUserData());
+ __pEdit = &(pSearchBarImpl->GetEditFieldImpl()->GetCore());
- r = __pEdit->Initialize(EDIT_STYLE_NORMAL | EDIT_STYLE_SINGLE_LINE | EDIT_STYLE_CLEAR | EDIT_STYLE_NOSCROLL, INPUT_STYLE_OVERLAY,
- SEARCHBAR_TEXT_LENGTH_MAX);
- SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+ SysTryReturnResult(NID_UI_CTRL, __pEdit != null, E_SYSTEM,
+ "[E_SYSTEM] A system error has occured. Failed to get _Edit instance");
__pEdit->SetKeypadCommandButtonVisible(false);
__pEdit->SetBounds(editBounds);
_ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
- __pCancelButton = _Button::CreateButtonN();
+ _SearchBarImpl* pSearchBarImpl = static_cast<_SearchBarImpl*>(GetUserData());
+ __pCancelButton = &(pSearchBarImpl->GetButtonImpl()->GetCore());
+
+ SysTryReturnResult(NID_UI_CTRL, __pCancelButton != null, E_SYSTEM,
+ "[E_SYSTEM] A system error has occured. Failed to get _Edit instance");
+
r = GetLastResult();
SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
result
_SearchBar::SetModeLocked(bool modeLocked)
{
+ if (modeLocked == true && GetMode() == SEARCH_BAR_MODE_NORMAL)
+ {
+ __pEdit->SetViewModeEnabled(true);
+ }
+
+ if (modeLocked == false && __pEdit->IsViewModeEnabled())
+ {
+ __pEdit->SetViewModeEnabled(false);
+ }
+
return __pSearchBarPresenter->SetModeLocked(modeLocked);
}
SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
"[E_SYSTEM] A system error has occurred. Failed to set text.");
+ __isButtonTextChangedByApp = true;
+
return r;
}
return _UI_TOUCH_EVENT_DELIVERY_YES;
}
- SetMode(SEARCH_BAR_MODE_INPUT);
-
return _UI_TOUCH_EVENT_DELIVERY_YES;
}
__pKeypadEvent->Fire(*pEventArg);
}
+ __isKeypadOpening = false;
+
SetContentsArea();
return;
}
bool
_SearchBar::OnFocusGained(const _Control& source)
{
- SetMode(SEARCH_BAR_MODE_INPUT);
- __pEdit->SetFocused();
- return false;
+ if (__isKeyPressed)
+ {
+ __isKeyPressed = false;
+ _Control::OnDrawFocus();
+
+ return true;
+ }
+
+ if (GetVisibleState() == true)
+ {
+ __pEdit->SetFocused();
+ }
+
+ return true;
}
bool
-_SearchBar::OnFocusLost(const _Control& source)
+_SearchBar::OnFocusLost(const _Control &source)
{
- return false;
+ __pEdit->SetSearchFieldFocus(false);
+ _Control::OnFocusLost(source);
+ return true;
}
bool
return false;
}
+ if (!__pEdit->IsSearchFieldFocused())
+ {
+ return false;
+ }
+
_KeyCode keyCode = keyInfo.GetKeyCode();
- if (keyCode == _KEY_RIGHT)
+ switch (keyCode)
{
- if (__isButtonEnabled)
- {
- __pEdit->SetFocused(false);
- __pCancelButton->SetButtonStatus(_BUTTON_STATUS_HIGHLIGHTED);
- __pCancelButton->SetFocused();
- __pCancelButton->Invalidate(true);
- }
+ case _KEY_RIGHT:
+ SetFocusCallbackParameter(false);
+ if (&source == __pEdit)
+ {
+ if ((!__isButtonEnabled || !__isUsableCancelButton) && __pContentControl && __pContentControl->GetVisibleState() && __pContentControl->GetEnableState())
+ {
+ __pContentControl->SetFocused();
+ __pContentControl->OnDrawFocus();
- return true;
- }
+ return true;
+ }
+ else if (__isButtonEnabled && __isUsableCancelButton)
+ {
+ __pCancelButton->SetFocused();
+ }
- if (keyCode == _KEY_LEFT)
- {
- if (__pCancelButton->GetButtonStatus() == _BUTTON_STATUS_HIGHLIGHTED)
- {
- __pCancelButton->SetButtonStatus(_BUTTON_STATUS_NORMAL);
- __pCancelButton->SetFocused(false);
- __pCancelButton->Invalidate();
+ return true;
+ }
- }
+ if (&source == __pCancelButton && __pContentControl && __pContentControl->GetVisibleState() && __pContentControl->GetEnableState())
+ {
+ __pContentControl->SetFocused();
+ __pContentControl->OnDrawFocus();
- if (__pCancelButton->GetButtonStatus() == _BUTTON_STATUS_DISABLED) //Searchbar Button is disabled, left arrow key is pressed
- {
- __pCancelButton->SetButtonStatus(_BUTTON_STATUS_NORMAL);
- SetButtonEnabled(false);
- }
+ return true;
+ }
- __pEdit->SetFocused();
+ break;
- return true;
+ case _KEY_LEFT:
+ if (&source == __pCancelButton)
+ {
+ __pEdit->SetFocused();
+ return true;
+ }
+
+ if (&source == __pContentControl)
+ {
+ if ((__isButtonEnabled && __isUsableCancelButton))
+ {
+ __pCancelButton->SetFocused();
+ }
+ else
+ {
+ __pEdit->SetFocused();
+ }
+ return true;
+ }
+
+ break;
+
+ case _KEY_ENTER:
+ if (&source == __pCancelButton)
+ {
+ SetMode(SEARCH_BAR_MODE_NORMAL);
+ __isKeyPressed = true;
+ SetFocused();
+ _Control::OnDrawFocus();
+
+ return true;
+ }
+
+ break;
+
+ default:
+ return false;
}
return false;
}
-bool
-_SearchBar::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
+void
+_SearchBar::OnSettingChanged(Tizen::Base::String& key)
{
- return false;
+ if (__isButtonTextChangedByApp || !__isUsableCancelButton)
+ {
+ return;
+ }
+
+ if (key.Equals(L"http://tizen.org/setting/locale.language", false))
+ {
+ String cancelText;
+ GET_STRING_CONFIG(IDS_COM_SK_CANCEL, cancelText);
+ __pCancelButton->SetText(cancelText);
+ __pCancelButton->Invalidate();
+ }
+
+ return;
}
_Control*
__pAccessibilitySearchBarElement->SetTrait(ACCESSIBILITY_TRAITS_NONE);
__pAccessibilitySearchBarElement->SetName("SearchBar");
pContainer->AddElement(*__pAccessibilitySearchBarElement);
- }
+ }
return;
}
return;
}
+void
+_SearchBar::OnDrawFocus(void)
+{
+ __pEdit->SetSearchFieldFocus(true);
+ return;
+}
+
bool
_SearchBar::IsContentAttachable(const _Control* pContent)
{
return;
}
+void
+_SearchBar::SetFocusCallbackParameter(bool state)
+{
+ __isFocusCallbackToBeFired = state;
+ return;
+}
+
+bool
+_SearchBar::IsFocusCallbackToBeFired(void) const
+{
+ return __isFocusCallbackToBeFired;
+}
}}} // Tizen::Ui::Controls