2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <input-method-options.h>
22 #include <input-method-devel.h>
24 using namespace Dali::InputMethod;
25 using namespace Dali::InputMethod::Category;
30 #define TOKEN_STRING(x) #x
32 struct InputMethodOptions::Impl
36 mPanelLayout = PanelLayout::NORMAL;
37 mAutoCapital = AutoCapital::SENTENCE;
38 mActionButton = ActionButtonTitle::DEFAULT;
39 mVariation = NormalLayout::NORMAL;
42 PanelLayout::Type mPanelLayout;
43 AutoCapital::Type mAutoCapital;
44 ActionButtonTitle::Type mActionButton;
48 InputMethodOptions::InputMethodOptions()
53 bool InputMethodOptions::IsPassword()
55 return (mImpl->mPanelLayout == Dali::InputMethod::PanelLayout::PASSWORD);
58 void InputMethodOptions::ApplyProperty( const Property::Map& settings )
60 for ( unsigned int i = 0, count = settings.Count(); i < count; ++i )
62 Property::Key key = settings.GetKeyAt( i );
63 if( key.type == Property::Key::INDEX )
68 Property::Value item = settings.GetValue(i);
70 if( key == TOKEN_STRING( PANEL_LAYOUT ) )
72 if( item.GetType() == Property::INTEGER )
74 int value = item.Get< int >();
75 mImpl->mPanelLayout = static_cast<InputMethod::PanelLayout::Type>(value);
78 else if ( key == TOKEN_STRING( AUTO_CAPITALISE ) )
80 if ( item.GetType() == Property::INTEGER )
82 int value = item.Get< int >();
83 mImpl->mAutoCapital = static_cast<InputMethod::AutoCapital::Type>(value);
86 else if ( key == TOKEN_STRING( ACTION_BUTTON ) )
88 if ( item.GetType() == Property::INTEGER )
90 int value = item.Get< int >();
91 mImpl->mActionButton = static_cast<InputMethod::ActionButtonTitle::Type>(value);
94 else if( key == TOKEN_STRING( VARIATION ) )
96 if( item.GetType() == Property::INTEGER )
98 int value = item.Get< int >();
99 mImpl->mVariation = value;
108 void InputMethodOptions::RetrieveProperty( Property::Map& settings )
110 settings[TOKEN_STRING( PANEL_LAYOUT )] = mImpl->mPanelLayout;
111 settings[TOKEN_STRING( AUTO_CAPITALISE )] = mImpl->mAutoCapital;
112 settings[TOKEN_STRING( ACTION_BUTTON )] = mImpl->mActionButton;
113 settings[TOKEN_STRING( VARIATION )] = mImpl->mVariation;
116 bool InputMethodOptions::CompareAndSet( InputMethod::Category::Type type, const InputMethodOptions& options, int& index)
118 bool updated = false;
124 if ( options.mImpl->mPanelLayout != mImpl->mPanelLayout )
126 mImpl->mPanelLayout = options.mImpl->mPanelLayout;
127 index = static_cast<int>(mImpl->mPanelLayout);
132 case AUTO_CAPITALISE:
134 if ( options.mImpl->mAutoCapital != mImpl->mAutoCapital )
136 mImpl->mAutoCapital = options.mImpl->mAutoCapital;
137 index = static_cast<int>(mImpl->mAutoCapital);
142 case ACTION_BUTTON_TITLE:
144 if ( options.mImpl->mActionButton != mImpl->mActionButton )
146 mImpl->mActionButton = options.mImpl->mActionButton;
147 index = static_cast<int>(mImpl->mActionButton);
154 if ( options.mImpl->mVariation != mImpl->mVariation )
156 mImpl->mVariation = options.mImpl->mVariation;
157 index = static_cast<int>(mImpl->mVariation);