| 677 | //----------------------------------------------------------------------------- |
| 678 | |
| 679 | bool GuiControl::onAdd() |
| 680 | { |
| 681 | // Let Parent Do Work. |
| 682 | if ( !Parent::onAdd() ) |
| 683 | return false; |
| 684 | |
| 685 | // Grab the classname of this object |
| 686 | const char *cName = getClassName(); |
| 687 | |
| 688 | // if we're a pure GuiControl, then we're a container by default. |
| 689 | if ( dStrcmp( "GuiControl", cName ) == 0 ) |
| 690 | mIsContainer = true; |
| 691 | |
| 692 | // Add to root group. |
| 693 | if ( mAddGroup == NULL ) |
| 694 | mAddGroup = Sim::getGuiGroup(); |
| 695 | mAddGroup->addObject(this); |
| 696 | |
| 697 | // If we don't have a profile we must assign one now. |
| 698 | // Try assigning one based on the control's class name... |
| 699 | if ( !mProfile ) |
| 700 | { |
| 701 | String name = getClassName(); |
| 702 | |
| 703 | if ( name.isNotEmpty() ) |
| 704 | { |
| 705 | U32 pos = name.find( "Ctrl" ); |
| 706 | |
| 707 | if ( pos != -1 ) |
| 708 | name.replace( pos, 4, "Profile" ); |
| 709 | else |
| 710 | name += "Profile"; |
| 711 | |
| 712 | GuiControlProfile *profile = NULL; |
| 713 | if ( Sim::findObject( name, profile ) ) |
| 714 | setControlProfile( profile ); |
| 715 | } |
| 716 | } |
| 717 | |
| 718 | // Try assigning the default profile... |
| 719 | if ( !mProfile ) |
| 720 | { |
| 721 | GuiControlProfile *profile = NULL; |
| 722 | Sim::findObject( "GuiDefaultProfile", profile ); |
| 723 | |
| 724 | AssertISV( profile != NULL, avar("GuiControl::onAdd() unable to find specified profile and GuiDefaultProfile does not exist!") ); |
| 725 | |
| 726 | setControlProfile( profile ); |
| 727 | } |
| 728 | |
| 729 | // We must also assign a valid TooltipProfile... |
| 730 | if ( !mTooltipProfile ) |
| 731 | { |
| 732 | GuiControlProfile *profile = NULL; |
| 733 | Sim::findObject( "GuiTooltipProfile", profile ); |
| 734 | |
| 735 | AssertISV( profile != NULL, avar("GuiControl::onAdd() unable to find specified tooltip profile and GuiTooltipProfile does not exist!") ); |
| 736 |
nothing calls this directly
no test coverage detected