2 * Copyright (c) 2015 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 <dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.h>
22 #include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup-callback-interface.h>
23 #include <dali-toolkit/public-api/controls/control-depth-index-ranges.h>
24 #include <dali-toolkit/public-api/controls/default-controls/solid-color-actor.h>
25 #include <dali-toolkit/public-api/controls/text-controls/text-label.h>
28 #include <dali/public-api/images/nine-patch-image.h>
29 #include <dali/public-api/images/resource-image.h>
30 #include <dali/public-api/math/vector2.h>
31 #include <dali/public-api/math/vector4.h>
32 #include <dali/devel-api/object/type-registry-helper.h>
47 // todo Move this to adaptor??
48 #define GET_LOCALE_TEXT(string) dgettext("elementary", string)
50 const std::string TEXT_SELECTION_POPUP_LABEL( "textselectionpopuplabel" );
51 const Dali::Vector4 DEFAULT_OPTION_PRESSED_COLOR( Dali::Vector4( 0.24f, 0.72f, 0.8f, 1.0f ) );
53 #ifdef DGETTEXT_ENABLED
55 #define POPUP_CUT_STRING GET_LOCALE_TEXT("IDS_COM_BODY_CUT")
56 #define POPUP_COPY_STRING GET_LOCALE_TEXT("IDS_COM_BODY_COPY")
57 #define POPUP_PASTE_STRING GET_LOCALE_TEXT("IDS_COM_BODY_PASTE")
58 #define POPUP_SELECT_STRING GET_LOCALE_TEXT("IDS_COM_SK_SELECT")
59 #define POPUP_SELECT_ALL_STRING GET_LOCALE_TEXT("IDS_COM_BODY_SELECT_ALL")
60 #define POPUP_CLIPBOARD_STRING GET_LOCALE_TEXT("IDS_COM_BODY_CLIPBOARD")
64 #define POPUP_CUT_STRING "Cut"
65 #define POPUP_COPY_STRING "Copy"
66 #define POPUP_PASTE_STRING "Paste"
67 #define POPUP_SELECT_STRING "Select"
68 #define POPUP_SELECT_ALL_STRING "Select All"
69 #define POPUP_CLIPBOARD_STRING "Clipboard"
73 const char* const OPTION_SELECT_WORD = "option-select_word"; // "Select Word" popup option.
74 const char* const OPTION_SELECT_ALL("option-select_all"); // "Select All" popup option.
75 const char* const OPTION_CUT("option-cut"); // "Cut" popup option.
76 const char* const OPTION_COPY("option-copy"); // "Copy" popup option.
77 const char* const OPTION_PASTE("option-paste"); // "Paste" popup option.
78 const char* const OPTION_CLIPBOARD("option-clipboard"); // "Clipboard" popup option.
82 return Toolkit::TextSelectionPopup::New( Toolkit::TextSelectionPopup::NONE, NULL );
85 // Setup properties, signals and actions using the type-registry.
87 DALI_TYPE_REGISTRATION_BEGIN( Toolkit::TextSelectionPopup, Toolkit::Control, Create );
89 DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionPopup, "popup-max-size", VECTOR2, POPUP_MAX_SIZE )
90 DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionPopup, "popup-min-size", VECTOR2, POPUP_MIN_SIZE )
91 DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionPopup, "option-max-size", VECTOR2, OPTION_MAX_SIZE )
92 DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionPopup, "option-min-size", VECTOR2, OPTION_MIN_SIZE )
93 DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionPopup, "option-divider-size", VECTOR2, OPTION_DIVIDER_SIZE )
94 DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionPopup, "popup-clipboard-button-image", STRING, POPUP_CLIPBOARD_BUTTON_ICON_IMAGE )
95 DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionPopup, "popup-cut-button-image", STRING, POPUP_CUT_BUTTON_ICON_IMAGE )
96 DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionPopup, "popup-copy-button-image", STRING, POPUP_COPY_BUTTON_ICON_IMAGE )
97 DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionPopup, "popup-paste-button-image", STRING, POPUP_PASTE_BUTTON_ICON_IMAGE )
98 DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionPopup, "popup-select-button-image", STRING, POPUP_SELECT_BUTTON_ICON_IMAGE )
99 DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionPopup, "popup-select-all-button-image", STRING, POPUP_SELECT_ALL_BUTTON_ICON_IMAGE )
100 DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionPopup, "popup-divider-color", VECTOR4, POPUP_DIVIDER_COLOR )
101 DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionPopup, "popup-icon-color", VECTOR4, POPUP_ICON_COLOR )
102 DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionPopup, "popup-pressed-color", VECTOR4, POPUP_PRESSED_COLOR )
103 DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionPopup, "popup-pressed-image", STRING, POPUP_PRESSED_IMAGE )
105 DALI_TYPE_REGISTRATION_END()
110 Dali::Toolkit::TextSelectionPopup TextSelectionPopup::New( Toolkit::TextSelectionPopup::Buttons buttonsToEnable,
111 TextSelectionPopupCallbackInterface* callbackInterface )
113 // Create the implementation, temporarily owned by this handle on stack
114 IntrusivePtr< TextSelectionPopup > impl = new TextSelectionPopup( callbackInterface );
116 // Pass ownership to CustomActor handle
117 Dali::Toolkit::TextSelectionPopup handle( *impl );
119 impl->mEnabledButtons = buttonsToEnable;
120 // Second-phase init of the implementation
121 // This can only be done after the CustomActor connection has been made...
127 void TextSelectionPopup::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
129 Toolkit::TextSelectionPopup selectionPopup = Toolkit::TextSelectionPopup::DownCast( Dali::BaseHandle( object ) );
133 TextSelectionPopup& impl( GetImpl( selectionPopup ) );
137 case Toolkit::TextSelectionPopup::Property::POPUP_MAX_SIZE:
139 impl.SetDimensionToCustomise( POPUP_MAXIMUM_SIZE, value.Get< Vector2 >() );
142 case Toolkit::TextSelectionPopup::Property::OPTION_MAX_SIZE:
144 impl.SetDimensionToCustomise( OPTION_MAXIMUM_SIZE, value.Get< Vector2 >() );
147 case Toolkit::TextSelectionPopup::Property::OPTION_MIN_SIZE:
149 impl.SetDimensionToCustomise( OPTION_MINIMUM_SIZE, value.Get< Vector2>() );
152 case Toolkit::TextSelectionPopup::Property::OPTION_DIVIDER_SIZE:
154 impl.SetDimensionToCustomise( OPTION_DIVIDER_SIZE, value.Get< Vector2>() );
157 case Toolkit::TextSelectionPopup::Property::POPUP_CLIPBOARD_BUTTON_ICON_IMAGE:
159 ResourceImage image = ResourceImage::New( value.Get< std::string >() );
160 impl.SetButtonImage( Toolkit::TextSelectionPopup::CLIPBOARD, image );
163 case Toolkit::TextSelectionPopup::Property::POPUP_CUT_BUTTON_ICON_IMAGE:
165 ResourceImage image = ResourceImage::New( value.Get< std::string >() );
166 impl.SetButtonImage( Toolkit::TextSelectionPopup::CUT, image );
169 case Toolkit::TextSelectionPopup::Property::POPUP_COPY_BUTTON_ICON_IMAGE:
171 ResourceImage image = ResourceImage::New( value.Get< std::string >() );
172 impl.SetButtonImage( Toolkit::TextSelectionPopup::COPY, image );
175 case Toolkit::TextSelectionPopup::Property::POPUP_PASTE_BUTTON_ICON_IMAGE:
177 ResourceImage image = ResourceImage::New( value.Get< std::string >() );
178 impl.SetButtonImage( Toolkit::TextSelectionPopup::PASTE, image );
181 case Toolkit::TextSelectionPopup::Property::POPUP_SELECT_BUTTON_ICON_IMAGE:
183 ResourceImage image = ResourceImage::New( value.Get< std::string >() );
184 impl.SetButtonImage( Toolkit::TextSelectionPopup::SELECT, image );
187 case Toolkit::TextSelectionPopup::Property::POPUP_SELECT_ALL_BUTTON_ICON_IMAGE:
189 ResourceImage image = ResourceImage::New( value.Get< std::string >() );
190 impl.SetButtonImage( Toolkit::TextSelectionPopup::SELECT_ALL, image );
193 case Toolkit::TextSelectionPopup::Property::POPUP_DIVIDER_COLOR:
195 impl.mDividerColor = value.Get< Vector4 >();
198 case Toolkit::TextSelectionPopup::Property::POPUP_ICON_COLOR:
200 impl.mIconColor = value.Get< Vector4 >();
203 case Toolkit::TextSelectionPopup::Property::POPUP_PRESSED_COLOR:
205 impl.mPressedColor = value.Get< Vector4 >();
208 case Toolkit::TextSelectionPopup::Property::POPUP_PRESSED_IMAGE:
210 impl.SetPressedImage( value.Get< std::string >() );
214 } // TextSelectionPopup
217 Property::Value TextSelectionPopup::GetProperty( BaseObject* object, Property::Index index )
219 Property::Value value;
221 Toolkit::TextSelectionPopup selectionPopup = Toolkit::TextSelectionPopup::DownCast( Dali::BaseHandle( object ) );
225 TextSelectionPopup& impl( GetImpl( selectionPopup ) );
229 case Toolkit::TextSelectionPopup::Property::POPUP_MAX_SIZE:
231 value = impl.GetDimensionToCustomise( POPUP_MAXIMUM_SIZE );
234 case Toolkit::TextSelectionPopup::Property::OPTION_MAX_SIZE:
236 value = impl.GetDimensionToCustomise( OPTION_MAXIMUM_SIZE );
239 case Toolkit::TextSelectionPopup::Property::OPTION_MIN_SIZE:
241 value = impl.GetDimensionToCustomise( OPTION_MINIMUM_SIZE );
244 case Toolkit::TextSelectionPopup::Property::OPTION_DIVIDER_SIZE:
246 value = impl.GetDimensionToCustomise( OPTION_DIVIDER_SIZE );
249 case Toolkit::TextSelectionPopup::Property::POPUP_CLIPBOARD_BUTTON_ICON_IMAGE:
251 ResourceImage image = ResourceImage::DownCast( impl.GetButtonImage( Toolkit::TextSelectionPopup::CLIPBOARD ) );
254 value = image.GetUrl();
258 case Toolkit::TextSelectionPopup::Property::POPUP_CUT_BUTTON_ICON_IMAGE:
260 ResourceImage image = ResourceImage::DownCast( impl.GetButtonImage( Toolkit::TextSelectionPopup::CUT ) );
263 value = image.GetUrl();
267 case Toolkit::TextSelectionPopup::Property::POPUP_COPY_BUTTON_ICON_IMAGE:
269 ResourceImage image = ResourceImage::DownCast( impl.GetButtonImage( Toolkit::TextSelectionPopup::COPY ) );
272 value = image.GetUrl();
276 case Toolkit::TextSelectionPopup::Property::POPUP_PASTE_BUTTON_ICON_IMAGE:
278 ResourceImage image = ResourceImage::DownCast( impl.GetButtonImage( Toolkit::TextSelectionPopup::PASTE ) );
281 value = image.GetUrl();
285 case Toolkit::TextSelectionPopup::Property::POPUP_SELECT_BUTTON_ICON_IMAGE:
287 ResourceImage image = ResourceImage::DownCast( impl.GetButtonImage( Toolkit::TextSelectionPopup::SELECT ) );
290 value = image.GetUrl();
294 case Toolkit::TextSelectionPopup::Property::POPUP_SELECT_ALL_BUTTON_ICON_IMAGE:
296 ResourceImage image = ResourceImage::DownCast( impl.GetButtonImage( Toolkit::TextSelectionPopup::SELECT_ALL ) );
299 value = image.GetUrl();
303 case Toolkit::TextSelectionPopup::Property::POPUP_PRESSED_IMAGE:
305 value = impl.GetPressedImage();
313 void TextSelectionPopup::RaiseAbove( Layer target )
317 mToolbar.RaiseAbove( target );
321 void TextSelectionPopup::ShowPopup()
323 AddPopupOptionsToToolbar( mShowIcons, mShowCaptions );
326 void TextSelectionPopup::OnInitialize()
331 void TextSelectionPopup::OnStageConnection( int depth )
333 // Call the Control::OnStageConnection() to set the depth of the background.
334 Control::OnStageConnection( depth );
336 // TextSelectionToolbar::OnStageConnection() will set the depths of all the popup's components.
339 bool TextSelectionPopup::OnCutButtonPressed( Toolkit::Button button )
341 if( mCallbackInterface )
343 mCallbackInterface->TextPopupButtonTouched( Toolkit::TextSelectionPopup::CUT );
349 bool TextSelectionPopup::OnCopyButtonPressed( Toolkit::Button button )
351 if( mCallbackInterface )
353 mCallbackInterface->TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::COPY );
359 bool TextSelectionPopup::OnPasteButtonPressed( Toolkit::Button button )
361 if( mCallbackInterface )
363 mCallbackInterface->TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::PASTE );
369 bool TextSelectionPopup::OnSelectButtonPressed( Toolkit::Button button )
371 if( mCallbackInterface )
373 mCallbackInterface->TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::SELECT );
379 bool TextSelectionPopup::OnSelectAllButtonPressed( Toolkit::Button button )
381 if( mCallbackInterface )
383 mCallbackInterface->TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::SELECT_ALL );
389 bool TextSelectionPopup::OnClipboardButtonPressed( Toolkit::Button button )
391 if( mCallbackInterface )
393 mCallbackInterface->TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::CLIPBOARD );
399 void TextSelectionPopup::SetDimensionToCustomise( const PopupCustomisations& settingToCustomise, const Size& dimension )
401 switch( settingToCustomise )
403 case POPUP_MAXIMUM_SIZE :
407 mToolbar.SetProperty( Toolkit::TextSelectionToolbar::Property::MAX_SIZE, dimension );
411 case OPTION_MAXIMUM_SIZE :
413 mOptionMaxSize = dimension;
414 // Option max size not currently currently supported
417 case OPTION_MINIMUM_SIZE :
419 mOptionMinSize = dimension;
420 // Option min size not currently currently supported
423 case OPTION_DIVIDER_SIZE :
425 mOptionDividerSize = dimension;
428 // Resize Dividers not currently supported
435 Size TextSelectionPopup::GetDimensionToCustomise( const PopupCustomisations& settingToCustomise )
437 switch( settingToCustomise )
439 case POPUP_MAXIMUM_SIZE :
441 return mToolbar.GetProperty( Toolkit::TextSelectionToolbar::Property::MAX_SIZE ).Get< Vector2 >();
443 case OPTION_MAXIMUM_SIZE :
445 return mOptionMaxSize;
447 case OPTION_MINIMUM_SIZE :
449 return mOptionMinSize;
451 case OPTION_DIVIDER_SIZE :
453 return mOptionDividerSize;
460 void TextSelectionPopup::SetButtonImage( Toolkit::TextSelectionPopup::Buttons button, Dali::Image image )
465 case Toolkit::TextSelectionPopup::CLIPBOARD:
467 mClipboardIconImage = image;
470 case Toolkit::TextSelectionPopup::CUT :
472 mCutIconImage = image;
475 case Toolkit::TextSelectionPopup::COPY :
477 mCopyIconImage = image;
480 case Toolkit::TextSelectionPopup::PASTE :
482 mPasteIconImage = image;
485 case Toolkit::TextSelectionPopup::SELECT :
487 mSelectIconImage = image;
490 case Toolkit::TextSelectionPopup::SELECT_ALL :
492 mSelectAllIconImage = image;
497 DALI_ASSERT_DEBUG( "TextSelectionPopup SetPopupImage Unknown Button" );
502 Dali::Image TextSelectionPopup::GetButtonImage( Toolkit::TextSelectionPopup::Buttons button )
506 case Toolkit::TextSelectionPopup::CLIPBOARD :
508 return mClipboardIconImage;
511 case Toolkit::TextSelectionPopup::CUT :
513 return mCutIconImage;
516 case Toolkit::TextSelectionPopup::COPY :
518 return mCopyIconImage;
521 case Toolkit::TextSelectionPopup::PASTE :
523 return mPasteIconImage;
526 case Toolkit::TextSelectionPopup::SELECT :
528 return mSelectIconImage;
531 case Toolkit::TextSelectionPopup::SELECT_ALL :
533 return mSelectAllIconImage;
538 DALI_ASSERT_DEBUG( "TextSelectionPopup GetPopupImage Unknown Button" );
542 return Dali::Image();
545 void TextSelectionPopup::SetPressedImage( const std::string& filename )
547 mPressedImage = filename;
550 std::string TextSelectionPopup::GetPressedImage() const
552 return mPressedImage;
555 void TextSelectionPopup::CreateOrderedListOfPopupOptions()
557 mOrderListOfButtons.clear();
558 mOrderListOfButtons.reserve( 8u );
560 // Create button for each possible option using Option priority
561 mOrderListOfButtons.push_back( ButtonRequirement( Toolkit::TextSelectionPopup::CUT, mCutOptionPriority, OPTION_CUT, POPUP_CUT_STRING , mCutIconImage, ( mEnabledButtons & Toolkit::TextSelectionPopup::CUT) ) );
562 mOrderListOfButtons.push_back( ButtonRequirement( Toolkit::TextSelectionPopup::COPY, mCopyOptionPriority, OPTION_COPY, POPUP_COPY_STRING, mCopyIconImage, ( mEnabledButtons & Toolkit::TextSelectionPopup::COPY) ) );
563 mOrderListOfButtons.push_back( ButtonRequirement( Toolkit::TextSelectionPopup::PASTE, mPasteOptionPriority, OPTION_PASTE, POPUP_PASTE_STRING, mPasteIconImage, ( mEnabledButtons & Toolkit::TextSelectionPopup::PASTE) ) );
564 mOrderListOfButtons.push_back( ButtonRequirement( Toolkit::TextSelectionPopup::SELECT, mSelectOptionPriority, OPTION_SELECT_WORD, POPUP_SELECT_STRING, mSelectIconImage, ( mEnabledButtons & Toolkit::TextSelectionPopup::SELECT) ) );
565 mOrderListOfButtons.push_back( ButtonRequirement( Toolkit::TextSelectionPopup::SELECT_ALL, mSelectAllOptionPriority, OPTION_SELECT_ALL, POPUP_SELECT_ALL_STRING, mSelectAllIconImage, ( mEnabledButtons & Toolkit::TextSelectionPopup::SELECT_ALL) ) );
566 mOrderListOfButtons.push_back( ButtonRequirement( Toolkit::TextSelectionPopup::CLIPBOARD, mClipboardOptionPriority, OPTION_CLIPBOARD, POPUP_CLIPBOARD_STRING, mClipboardIconImage, ( mEnabledButtons & Toolkit::TextSelectionPopup::CLIPBOARD) ) );
568 // Sort the buttons according their priorities.
569 std::sort( mOrderListOfButtons.begin(), mOrderListOfButtons.end(), TextSelectionPopup::ButtonPriorityCompare() );
572 void TextSelectionPopup::AddOption( const ButtonRequirement& button, bool showDivider, bool showIcons, bool showCaption )
574 // 1. Create a option.
575 Toolkit::PushButton option = Toolkit::PushButton::New();
576 option.SetName( button.name );
577 option.SetAnimationTime( 0.0f );
578 option.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
582 case Toolkit::TextSelectionPopup::CUT:
584 option.ClickedSignal().Connect( this, &TextSelectionPopup::OnCutButtonPressed );
587 case Toolkit::TextSelectionPopup::COPY:
589 option.ClickedSignal().Connect( this, &TextSelectionPopup::OnCopyButtonPressed );
592 case Toolkit::TextSelectionPopup::PASTE:
594 option.ClickedSignal().Connect( this, &TextSelectionPopup::OnPasteButtonPressed );
597 case Toolkit::TextSelectionPopup::SELECT:
599 option.ClickedSignal().Connect( this, &TextSelectionPopup::OnSelectButtonPressed );
602 case Toolkit::TextSelectionPopup::SELECT_ALL:
604 option.ClickedSignal().Connect( this, &TextSelectionPopup::OnSelectAllButtonPressed );
607 case Toolkit::TextSelectionPopup::CLIPBOARD:
609 option.ClickedSignal().Connect( this, &TextSelectionPopup::OnClipboardButtonPressed );
612 case Toolkit::TextSelectionPopup::NONE:
619 // 2. Set the options contents.
622 option.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, Vector4( 24.0f, 24.0f, 14.0f, 14.0f ) );
623 option.SetLabelText( button.caption );
627 option.SetProperty( Toolkit::PushButton::Property::ICON_PADDING, Vector4( 10.0f, 10.0f, 10.0f, 10.0f ) );
628 option.SetProperty( Toolkit::PushButton::Property::ICON_ALIGNMENT, "TOP" );
630 // TODO: This is temporarily disabled until the text-selection-popup image API is changed to strings.
631 //option.SetProperty( Toolkit::PushButton::Property::SELECTED_ICON, button.icon );
632 //option.SetProperty( Toolkit::PushButton::Property::UNSELECTED_ICON, button.icon );
635 // 3. Set the normal option image (blank / Transparent).
636 option.SetUnselectedImage( "" );
638 // 4. Set the pressed option image.
639 // The image can be blank, the color can be used regardless.
640 option.SetSelectedImage( mPressedImage );
641 option.SetProperty( Toolkit::Button::Property::SELECTED_COLOR, mPressedColor );
643 // 5 Add option to tool bar
644 mToolbar.AddOption( option );
646 // 6. Add the divider
649 const Size size( mOptionDividerSize.width, 0.0f ); // Height FILL_TO_PARENT
651 ImageActor divider = Toolkit::CreateSolidColorActor( Color::WHITE );
652 #ifdef DECORATOR_DEBUG
653 divider.SetName("Text's popup divider");
655 divider.SetSize( size );
656 divider.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT );
657 divider.SetColor( mDividerColor );
658 divider.SetSortModifier( DECORATION_DEPTH_INDEX );
659 mToolbar.AddDivider( divider );
663 std::size_t TextSelectionPopup::GetNumberOfEnabledOptions()
665 std::size_t numberOfOptions = 0u;
666 for( std::vector<ButtonRequirement>::const_iterator it = mOrderListOfButtons.begin(), endIt = mOrderListOfButtons.end(); ( it != endIt ); ++it )
668 const ButtonRequirement& button( *it );
675 return numberOfOptions;
678 void TextSelectionPopup::AddPopupOptionsToToolbar( bool showIcons, bool showCaptions )
680 // Iterate list of buttons and add active ones to Toolbar
681 std::size_t numberOfOptionsRequired = GetNumberOfEnabledOptions();
682 std::size_t numberOfOptionsAdded = 0u;
683 for( std::vector<ButtonRequirement>::const_iterator it = mOrderListOfButtons.begin(), endIt = mOrderListOfButtons.end(); ( it != endIt ); ++it )
685 const ButtonRequirement& button( *it );
686 if ( button.enabled )
688 numberOfOptionsAdded++;
689 AddOption( button, ( numberOfOptionsAdded < numberOfOptionsRequired ) , showIcons, showCaptions );
694 void TextSelectionPopup::CreatePopup()
697 CreateOrderedListOfPopupOptions();
698 self.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
702 mToolbar = Toolkit::TextSelectionToolbar::New();
703 mToolbar.SetParentOrigin( ParentOrigin::CENTER );
704 self.Add( mToolbar );
708 TextSelectionPopup::TextSelectionPopup( TextSelectionPopupCallbackInterface* callbackInterface )
709 : Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ),
711 mOptionDividerSize(),
712 mEnabledButtons( Toolkit::TextSelectionPopup::NONE ),
713 mCallbackInterface( callbackInterface ),
714 mPressedColor( DEFAULT_OPTION_PRESSED_COLOR ),
715 mDividerColor( Color::WHITE ),
716 mIconColor( Color::WHITE ),
717 mSelectOptionPriority( 1 ),
718 mSelectAllOptionPriority ( 2 ),
719 mCutOptionPriority ( 4 ),
720 mCopyOptionPriority ( 3 ),
721 mPasteOptionPriority ( 5 ),
722 mClipboardOptionPriority( 6 ),
724 mShowCaptions( true )
728 TextSelectionPopup::~TextSelectionPopup()
733 } // namespace Internal
735 } // namespace Toolkit