+ Actor& selectedImage = checkBoxImpl.GetSelectedImage();
+ Actor& fadeOutSelectedImage = checkBoxImpl.GetFadeOutSelectedImage();
+
+ Toolkit::CheckBoxButton& checkBox = static_cast<Toolkit::CheckBoxButton&>( button );
+
+ switch( mPaintState )
+ {
+ case SelectedState:
+ {
+ if( selectedImage && selectedImage.GetParent() )
+ {
+ StopCheckOutAnimation( checkBox );
+ FadeOutImage( checkBox, Foreground, selectedImage );
+
+ selectedImage = image;
+
+ FadeInImage( checkBox, selectedImage );
+
+ StartCheckOutAnimation( checkBox );
+ StartCheckInAnimation();
+ }
+ else
+ {
+ selectedImage = image;
+ checkBox.Add( selectedImage );
+ }
+ break;
+ }
+ case UnselectedSelectedTransition: // FALLTHROUGH
+ case DisabledSelectedTransition:
+ {
+ StopCheckInAnimation();
+ checkBox.Remove( selectedImage );
+
+ selectedImage = image;
+
+ FadeInImage( checkBox, selectedImage );
+ StartCheckInAnimation();
+ break;
+ }
+ case SelectedUnselectedTransition: // FALLTHROUGH
+ case SelectedDisabledTransition:
+ {
+ float opacity = 1.f;
+ if( fadeOutSelectedImage )
+ {
+ opacity = fadeOutSelectedImage.GetCurrentOpacity();
+ }
+ StopCheckOutAnimation( checkBox );
+
+ // Replaces the button image.
+ selectedImage = image;
+
+ checkBox.Add( selectedImage );
+ FadeOutImage( checkBox, Foreground, selectedImage, opacity );
+
+ StartCheckOutAnimation( checkBox );
+ break;
+ }
+ default:
+ {
+ selectedImage = image;
+ break;
+ }
+ }
+
+ selectedImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ selectedImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ ApplySelectedConstraint( selectedImage, FOREGROUND_DEPTH );
+}
+
+void CheckBoxButtonDefaultPainter::SetBackgroundImage( Toolkit::Button& button, Actor image )
+{
+ Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetCheckBoxButtonImpl( button );
+ Actor& backgroundImage = checkBoxImpl.GetBackgroundImage();
+ Actor& fadeOutBackgroundImage = checkBoxImpl.GetFadeOutBackgroundImage();
+
+ Toolkit::CheckBoxButton& checkBox = static_cast<Toolkit::CheckBoxButton&>( button );
+
+ switch( mPaintState )
+ {
+ case UnselectedState: // FALLTHROUGH
+ case SelectedState:
+ case UnselectedSelectedTransition:
+ case SelectedUnselectedTransition:
+ {
+ if( backgroundImage && backgroundImage.GetParent() )
+ {
+ StopCheckOutAnimation( checkBox );
+ FadeOutImage( checkBox, Background, backgroundImage );
+
+ backgroundImage = image;
+
+ FadeInImage( checkBox, backgroundImage );
+
+ StartCheckOutAnimation( checkBox );
+ StartCheckInAnimation();
+ }
+ else
+ {
+ backgroundImage = image;
+ checkBox.Add( backgroundImage );
+ }
+ break;
+ }
+ case DisabledUnselectedTransition: // FALLTHROUGH
+ case DisabledSelectedTransition:
+ {
+ StopCheckInAnimation();
+ checkBox.Remove( backgroundImage );
+
+ backgroundImage = image;
+
+ FadeInImage( checkBox, backgroundImage );
+ StartCheckInAnimation();
+ break;
+ }
+ case SelectedDisabledTransition: // FALLTHROUGH
+ case UnselectedDisabledTransition:
+ {
+ float opacity = 1.f;
+ if( fadeOutBackgroundImage )
+ {
+ opacity = fadeOutBackgroundImage.GetCurrentOpacity();
+ }
+ StopCheckOutAnimation( checkBox );
+
+ // Replaces the button image.
+ backgroundImage = image;
+
+ checkBox.Add( backgroundImage );
+ FadeOutImage( checkBox, Background, backgroundImage, opacity );
+
+ StartCheckOutAnimation( checkBox );
+ break;
+ }
+ default:
+ {
+ backgroundImage = image;
+ break;
+ }
+ }
+
+ backgroundImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ backgroundImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ ApplyConstraint( backgroundImage, BACKGROUND_DEPTH );
+}
+
+void CheckBoxButtonDefaultPainter::SetDisabledSelectedImage( Toolkit::Button& button, Actor image )
+{
+ Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetCheckBoxButtonImpl( button );
+ Actor& disabledSelectedImage = checkBoxImpl.GetDisabledSelectedImage();
+ Actor& fadeOutSelectedImage = checkBoxImpl.GetFadeOutSelectedImage();
+
+ Toolkit::CheckBoxButton& checkBox = static_cast<Toolkit::CheckBoxButton&>( button );
+
+ switch( mPaintState )
+ {
+ case DisabledSelectedState:
+ {
+ if( disabledSelectedImage && disabledSelectedImage.GetParent() )
+ {
+ StopCheckOutAnimation( checkBox );
+ FadeOutImage( checkBox, Foreground, disabledSelectedImage );
+
+ disabledSelectedImage = image;
+
+ FadeInImage( checkBox, disabledSelectedImage );
+
+ StartCheckOutAnimation( checkBox );
+ StartCheckInAnimation();
+ }
+ else
+ {
+ disabledSelectedImage = image;
+ checkBox.Add( disabledSelectedImage );
+ }
+ break;
+ }
+ case SelectedDisabledTransition:
+ {
+ StopCheckInAnimation();
+ checkBox.Remove( disabledSelectedImage );
+
+ disabledSelectedImage = image;
+
+ FadeInImage( checkBox, disabledSelectedImage );
+ StartCheckInAnimation();
+ break;
+ }
+ case DisabledSelectedTransition:
+ {
+ float opacity = 1.f;
+ if( fadeOutSelectedImage )
+ {
+ opacity = fadeOutSelectedImage.GetCurrentOpacity();
+ }
+ StopCheckOutAnimation( checkBox );
+
+ // Replaces the button image.
+ disabledSelectedImage = image;
+
+ checkBox.Add( disabledSelectedImage );
+ FadeOutImage( checkBox, Foreground, disabledSelectedImage, opacity );
+
+ StartCheckOutAnimation( checkBox );
+ break;
+ }
+ default:
+ {
+ disabledSelectedImage = image;
+ break;
+ }
+ }
+
+ disabledSelectedImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ disabledSelectedImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ ApplyConstraint( disabledSelectedImage, FOREGROUND_DEPTH );
+}
+
+void CheckBoxButtonDefaultPainter::SetDisabledBackgroundImage( Toolkit::Button& button, Actor image )
+{
+ Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetCheckBoxButtonImpl( button );
+ Actor& disabledBackgroundImage = checkBoxImpl.GetDisabledBackgroundImage();
+ Actor& fadeOutBackgroundImage = checkBoxImpl.GetFadeOutBackgroundImage();
+
+ Toolkit::CheckBoxButton& checkBox = static_cast<Toolkit::CheckBoxButton&>( button );
+
+ switch( mPaintState )
+ {
+ case DisabledSelectedState: // FALLTHROUGH
+ case DisabledUnselectedState:
+ {
+ if( disabledBackgroundImage && disabledBackgroundImage.GetParent() )
+ {
+ StopCheckOutAnimation( checkBox );
+ FadeOutImage( checkBox, Background, disabledBackgroundImage );
+
+ disabledBackgroundImage = image;
+
+ FadeInImage( checkBox, disabledBackgroundImage );
+
+ StartCheckOutAnimation( checkBox );
+ StartCheckInAnimation();
+ }
+ else
+ {
+ disabledBackgroundImage = image;
+ checkBox.Add( disabledBackgroundImage );
+ }
+ break;
+ }
+ case UnselectedDisabledTransition: // FALLTHROUGH
+ case SelectedDisabledTransition:
+ {
+ StopCheckInAnimation();
+ checkBox.Remove( disabledBackgroundImage );
+
+ disabledBackgroundImage = image;
+
+ FadeInImage( checkBox, disabledBackgroundImage );
+ StartCheckInAnimation();
+ break;
+ }
+ case DisabledUnselectedTransition: // FALLTHROUGH
+ case DisabledSelectedTransition:
+ {
+ float opacity = 1.f;
+ if( fadeOutBackgroundImage )
+ {
+ opacity = fadeOutBackgroundImage.GetCurrentOpacity();
+ }
+ StopCheckOutAnimation( checkBox );
+
+ // Replaces the button image.
+ disabledBackgroundImage = image;
+
+ checkBox.Add( disabledBackgroundImage );
+ FadeOutImage( checkBox, Background, disabledBackgroundImage, opacity );
+
+ StartCheckOutAnimation( checkBox );
+ break;
+ }
+ default:
+ {
+ disabledBackgroundImage = image;
+ break;
+ }
+ }
+
+ disabledBackgroundImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ disabledBackgroundImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ ApplyConstraint( disabledBackgroundImage, BACKGROUND_DEPTH );
+}
+
+void CheckBoxButtonDefaultPainter::Selected( Toolkit::Button& button )
+{
+ Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetCheckBoxButtonImpl( button );
+ Actor& selectedImage = checkBoxImpl.GetSelectedImage();
+ Actor& fadeOutSelectedImage = checkBoxImpl.GetFadeOutSelectedImage();
+
+ Toolkit::CheckBoxButton& checkBoxButton = static_cast<Toolkit::CheckBoxButton&>( button );