+ unsigned int backgroundIndex;
+ unsigned int buttonIndex;
+
+ bool animationStarted = false;
+
+ mDisabled = disabled;
+
+ switch( mPaintState )
+ {
+ case UnselectedState:
+ {
+ buttonIndex = FindChildIndex( mLabel );
+ InsertChild( buttonIndex, mDisabledContent );
+
+ if( mBackgroundContent )
+ {
+ backgroundIndex = 1;
+ }
+ else
+ {
+ backgroundIndex = 0;
+ }
+
+ InsertChild( backgroundIndex, mDisabledBackgroundContent );
+
+ animationStarted = OnDisabled();
+
+ if( animationStarted )
+ {
+ mPaintState = UnselectedDisabledTransition;
+ }
+ else
+ {
+ mPaintState = DisabledUnselectedState;
+ }
+ break;
+ }
+ case SelectedState:
+ {
+ buttonIndex = FindChildIndex( mLabel );
+ InsertChild( buttonIndex, mDisabledSelectedContent );
+
+ if( mBackgroundContent )
+ {
+ backgroundIndex = 1;
+ }
+ else
+ {
+ backgroundIndex = 0;
+ }
+
+ InsertChild( backgroundIndex, mDisabledBackgroundContent );
+
+ animationStarted = OnDisabled();
+
+ if( animationStarted )
+ {
+ mPaintState = SelectedDisabledTransition;
+ }
+ else
+ {
+ mPaintState = DisabledSelectedState;
+ }
+ break;
+ }
+ case DisabledUnselectedState:
+ {
+ buttonIndex = FindChildIndex( mLabel );
+ InsertChild( buttonIndex, mButtonContent );
+
+ if( mDisabledBackgroundContent )
+ {
+ backgroundIndex = 1;
+ }
+ else
+ {
+ backgroundIndex = 0;
+ }
+
+ InsertChild( backgroundIndex, mBackgroundContent );
+
+ animationStarted = OnDisabled();
+
+ if( animationStarted )
+ {
+ mPaintState = DisabledUnselectedTransition;
+ }
+ else
+ {
+ mPaintState = UnselectedState;
+ }
+ break;
+ }
+ case DisabledSelectedState:
+ {
+ buttonIndex = FindChildIndex( mLabel );
+ InsertChild( buttonIndex, mSelectedContent );
+
+ if( mDisabledBackgroundContent )
+ {
+ backgroundIndex = 1;
+ }
+ else
+ {
+ backgroundIndex = 0;
+ }
+
+ InsertChild( backgroundIndex, mSelectedBackgroundContent );
+ InsertChild( backgroundIndex, mBackgroundContent );
+
+ animationStarted = OnDisabled();
+
+ if( animationStarted )
+ {
+ mPaintState = DisabledSelectedTransition;
+ }
+ else
+ {
+ mPaintState = SelectedState;
+ }
+ break;
+ }
+ case UnselectedSelectedTransition:
+ {
+ buttonIndex = FindChildIndex( mLabel );
+ InsertChild( buttonIndex, mDisabledSelectedContent );
+
+ if( mBackgroundContent )
+ {
+ backgroundIndex = 1;
+ }
+ else
+ {
+ backgroundIndex = 0;
+ }
+
+ InsertChild( backgroundIndex, mDisabledBackgroundContent );
+
+ animationStarted = OnDisabled();
+
+ if( animationStarted )
+ {
+ mPaintState = SelectedDisabledTransition;
+ }
+ else
+ {
+ mPaintState = DisabledSelectedState;
+ }
+ break;
+ }
+ case SelectedUnselectedTransition:
+ {
+ buttonIndex = FindChildIndex( mLabel );
+ InsertChild( buttonIndex, mDisabledContent );
+
+ if( mBackgroundContent )
+ {
+ backgroundIndex = 1;
+ }
+ else
+ {
+ backgroundIndex = 0;
+ }
+
+ InsertChild( backgroundIndex, mDisabledBackgroundContent );
+
+ animationStarted = OnDisabled();
+
+ if( animationStarted )
+ {
+ mPaintState = UnselectedDisabledTransition;
+ }
+ else
+ {
+ mPaintState = DisabledUnselectedState;
+ }
+ break;
+ }
+ case UnselectedDisabledTransition:
+ {
+ animationStarted = OnDisabled();
+
+ if( animationStarted )
+ {
+ mPaintState = DisabledUnselectedTransition;
+ }
+ else
+ {
+ mPaintState = UnselectedState;
+ }
+ break;
+ }
+ case DisabledUnselectedTransition:
+ {
+ animationStarted = OnDisabled();
+
+ if( animationStarted )
+ {
+ mPaintState = UnselectedDisabledTransition;
+ }
+ else
+ {
+ mPaintState = DisabledUnselectedState;
+ }
+ break;
+ }
+ case SelectedDisabledTransition:
+ {
+ animationStarted = OnDisabled();
+
+ if( animationStarted )
+ {
+ mPaintState = DisabledSelectedTransition;
+ }
+ else
+ {
+ mPaintState = SelectedState;
+ }
+ break;
+ }
+ case DisabledSelectedTransition:
+ {
+ animationStarted = OnDisabled();
+
+ if( animationStarted )
+ {
+ mPaintState = SelectedDisabledTransition;
+ }
+ else
+ {
+ mPaintState = DisabledSelectedState;
+ }
+ break;
+ }
+ }