//************************************************************************* // Method: RefreshLayoutOfGroup // Description: refreshes the layout of the panes in a group based on positions // // Parameters: // group - the group to refresh // // Return Value: None //************************************************************************* void DockablePaneManager::RefreshLayoutOfGroup(String *group) { ArrayList *list = dynamic_cast<ArrayList *>(groupToContentListTable->get_Item(group)); if (!list || list->Count == 0) return; WindowContent *windowContent; // put them in the correct order in a new list ArrayList *orderedList = new ArrayList(); IEnumerator *enumerator = list->GetEnumerator(); while (enumerator->MoveNext()) { Content *content = dynamic_cast<Content *>(enumerator->Current); if (!content) continue; DockablePane *pane = dynamic_cast<DockablePane *>(content->Control); if (!pane) continue; windowContent = content->ParentWindowContent; int insertPos = GetInsertPositionForContentList(orderedList, pane); orderedList->Insert(insertPos, content); } // remove all the panes enumerator = orderedList->GetEnumerator(); while (enumerator->MoveNext()) { Content *content = dynamic_cast<Content *>(enumerator->Current); if (!content) continue; if (dockManager->Contents && dockManager->Contents->Contains(content)) dockManager->Contents->Remove(content); list->Remove(content); } groupToContentListTable->Remove(group); // put them back in the right order enumerator = orderedList->GetEnumerator(); while (enumerator->MoveNext()) { Content *content = dynamic_cast<Content *>(enumerator->Current); if (!content) continue; DockablePane *pane = dynamic_cast<DockablePane *>(content->Control); if (!pane) continue; AddPane(pane); } }
//************************************************************************* // Method: RefreshLayout // Description: refreshes the layout of the pane groups based on positions // // Parameters: // None // // Return Value: None //************************************************************************* void DockablePaneManager::RefreshLayout() { lastVerticalLeftContentAdded = NULL; lastVerticalRightContentAdded = NULL; lastHorizontalTopContentAdded = NULL; lastHorizontalBottomContentAdded = NULL; ArrayList *groupNames = new ArrayList(); IEnumerator *enumerator = groupToContentListTable->Keys->GetEnumerator(); while (enumerator->MoveNext()) { String *group = dynamic_cast<String *>(enumerator->Current); if (!group) continue; groupNames->Add(group); } enumerator = groupNames->GetEnumerator(); while (enumerator->MoveNext()) { String *group = dynamic_cast<String *>(enumerator->Current); if (!group) continue; RefreshLayoutOfGroup(group); } }
//************************************************************************* // Method: GetIsPaneVisible // Description: gets whether or not a pane is visible // // Parameters: // pane - the pane to set the visibility of // // Return Value: true if the pane is visible, false otherwise //************************************************************************* bool DockablePaneManager::GetIsPaneVisible(DockablePane *pane) { if (!pane) return false; ArrayList *list; IEnumerator *enumerator; // check the pane list for the pane list = dynamic_cast<ArrayList *>(groupToContentListTable->get_Item(pane->Group)); if (list && (list->Count > 0)) { enumerator = list->GetEnumerator(); while (enumerator->MoveNext()) { Content *currContent = dynamic_cast<Content *>(enumerator->Current); if (!currContent) continue; DockablePane *currPane = dynamic_cast<DockablePane *>(currContent->Control); if (currPane && (currPane->Name->Equals(pane->Name))) { return currContent->Visible; } } } return false; }
//************************************************************************* // Method: SetPaneIsVisible // Description: sets whether or not a pane is visible // // Parameters: // pane - the pane to set the visibility of // isVisible - true to make the pane visible, false otherwise // // Return Value: None //************************************************************************* void DockablePaneManager::SetPaneIsVisible(DockablePane *pane, bool isVisible) { if (!pane) return; ArrayList *list; IEnumerator *enumerator; // check the pane list for the pane list = dynamic_cast<ArrayList *>(groupToContentListTable->get_Item(pane->Group)); if (list && (list->Count > 0)) { enumerator = list->GetEnumerator(); while (enumerator->MoveNext()) { Content *currContent = dynamic_cast<Content *>(enumerator->Current); if (!currContent) continue; DockablePane *currPane = dynamic_cast<DockablePane *>(currContent->Control); if (currPane && (currPane->Name->Equals(pane->Name))) { if (isVisible) dockManager->ShowContent(currContent); else dockManager->HideContent(currContent); } } } }
//************************************************************************* // Method: GetPane // Description: gets a dockable pane based on group and name // // Parameters: // group - the group name of the pane // name - the name of the pane // // Return Value: the pane if found, NULL otherwise //************************************************************************* DockablePane *DockablePaneManager::GetPane(String *group, String *name) { if (!group || !name) return NULL; ArrayList *list; IEnumerator *enumerator; // check the pane list list = dynamic_cast<ArrayList *>(groupToContentListTable->get_Item(group)); if (list && (list->Count > 0)) { enumerator = list->GetEnumerator(); while (enumerator->MoveNext()) { Content *currContent = dynamic_cast<Content *>(enumerator->Current); if (!currContent) continue; DockablePane *currPane = dynamic_cast<DockablePane *>(currContent->Control); if (currPane && (currPane->Name->Equals(name))) return currPane; } } // not found, return null return NULL; }
//************************************************************************* // Method: GetContentForPane // Description: gets the content that contains the specified pane // // Parameters: // pane - the pane to get the content for // // Return Value: the content containing the pane, or NULL if failed //************************************************************************* Content *DockablePaneManager::GetContentForPane(DockablePane *pane) { ArrayList *list; IEnumerator *enumerator; // check the pane list for the pane list = dynamic_cast<ArrayList *>(groupToContentListTable->get_Item(pane->Group)); if (list && (list->Count > 0)) { enumerator = list->GetEnumerator(); while (enumerator->MoveNext()) { Content *currContent = dynamic_cast<Content *>(enumerator->Current); if (!currContent) continue; DockablePane *currPane = dynamic_cast<DockablePane *>(currContent->Control); if (currPane && (currPane == pane)) return currContent; } } return NULL; }
//************************************************************************* // Method: RemovePane // Description: removes a pane from the control // // Parameters: // pane - the pane to remove // // Return Value: None //************************************************************************* void DockablePaneManager::RemovePane(DockablePane *pane) { if (!pane || !pane->Group || !pane->Name) return; Content *content = GetContentForPane(pane); if (!content) return; ArrayList *list = dynamic_cast<ArrayList *>(groupToContentListTable->get_Item(pane->Group)); if (!list) return; pane->OnNameChanged -= PaneNameChangedHandler; pane->OnTitleChanged -= PaneTitleChangedHandler; pane->OnImageIndexChanged -= PaneImageIndexChangedHandler; DockablePaneOrientation orientation = pane->PreferredOrientation; list->Remove(content); if (dockManager->Contents && dockManager->Contents->Contains(content)) dockManager->Contents->Remove(content); if (list->Count == 0) groupToContentListTable->Remove(pane->Group); switch(orientation) { case DockablePaneOrientation::VerticalLeft: lastVerticalLeftContentAdded = NULL; break; case DockablePaneOrientation::VerticalRight: lastVerticalRightContentAdded = NULL; break; case DockablePaneOrientation::HorizontalTop: lastHorizontalTopContentAdded = NULL; break; case DockablePaneOrientation::HorizontalBottom: lastHorizontalBottomContentAdded = NULL; break; } // make some other pane the last vertical or horizontal IEnumerator *enumerator = groupToContentListTable->Values->GetEnumerator(); while (enumerator->MoveNext()) { ArrayList *currList = dynamic_cast<ArrayList *>(enumerator->Current); if (!currList) continue; IEnumerator *listEnum = currList->GetEnumerator(); while (listEnum->MoveNext()) { Content *currContent = dynamic_cast<Content *>(listEnum->Current); if (!currContent) continue; DockablePane *currPane = dynamic_cast<DockablePane *>(currContent->Control); if (!currPane) continue; if (currPane->PreferredOrientation == orientation) { switch(orientation) { case DockablePaneOrientation::VerticalLeft: lastVerticalLeftContentAdded = currContent; break; case DockablePaneOrientation::VerticalRight: lastVerticalRightContentAdded = currContent; break; case DockablePaneOrientation::HorizontalTop: lastHorizontalTopContentAdded = currContent; break; case DockablePaneOrientation::HorizontalBottom: lastHorizontalBottomContentAdded = currContent; break; } } } } }