//------------------------------------------------------------------------ void SelectionMover::AlignSelection(const Alignment alignment) { // Validations wxASSERT_MSG(m_selection != NULL, wxT("Selection member is NULL")); if(m_selection->Size() <= 1) { // Should not happen because of the disabled menu/toolbar item in this case LogWarning(wxT("You must select more than one window to align!")); return; } // The first selected window is the one to match. This is for example how Visual Studio's // dialog editor works as well. Selection::Boxes::iterator boxIt = m_selection->GetMoveableBoxes().begin(); CEGUI::Window *current = boxIt->GetWindow(); const CEGUI::URect rect = current->getArea(); ++boxIt; for(; boxIt != m_selection->GetMoveableBoxes().end(); ++boxIt) { // Deny when it is blocked if (boxIt->IsLocked()) continue; current = boxIt->GetWindow(); switch(alignment) { case AlignLeft: current->setPosition(CEGUI::UVector2(rect.d_min.d_x, current->getPosition().d_y)); break; case AlignRight: current->setPosition(CEGUI::UVector2(rect.d_max.d_x - current->getWidth(), current->getPosition().d_y)); break; case AlignTop: current->setPosition(CEGUI::UVector2(current->getPosition().d_x, rect.d_min.d_y)); break; case AlignBottom: current->setPosition(CEGUI::UVector2(current->getPosition().d_x, rect.d_max.d_y - current->getHeight())); break; case AlignWidth: // The svn diff for this block will be big; no clue what the previous code // was doing there.. current->setWidth(rect.getWidth()); break; case AlignHeight: // The svn diff for this block will be big; no clue what the previous code // was doing there.. current->setHeight(rect.getHeight()); break; default: LogError(wxT("SelectionMover::AlignSelection - Unrecognized align option (%d)"), alignment); return; } } // Request for a repaint wxGetApp().GetMainFrame()->Refresh(); }