| 876 | } |
| 877 | |
| 878 | void PartStack::Replace(LayoutPart::Pointer oldChild, LayoutPart::Pointer newChild) |
| 879 | { |
| 880 | ChildVector::iterator loc = std::find(children.begin(), children.end(), oldChild); |
| 881 | int idx = 0; |
| 882 | int numPlaceholders = 0; |
| 883 | //subtract the number of placeholders still existing in the list |
| 884 | //before this one - they wont have parts. |
| 885 | for (ChildVector::iterator iter = children.begin(); iter != loc; ++iter, ++idx) |
| 886 | { |
| 887 | if ((*iter)->IsPlaceHolder()) |
| 888 | { |
| 889 | numPlaceholders++; |
| 890 | } |
| 891 | } |
| 892 | ObjectInt::Pointer cookie(new ObjectInt(idx - numPlaceholders)); |
| 893 | children.insert(loc, newChild); |
| 894 | |
| 895 | this->ShowPart(newChild, cookie); |
| 896 | |
| 897 | if (oldChild == requestedCurrent && newChild.Cast<PartPane>() != 0) |
| 898 | { |
| 899 | this->SetSelection(newChild.Cast<PartPane>()); |
| 900 | } |
| 901 | |
| 902 | this->Remove(oldChild); |
| 903 | } |
| 904 | |
| 905 | int PartStack::ComputePreferredSize(bool width, int availableParallel, |
| 906 | int availablePerpendicular, int preferredParallel) |