//------------------------------------------------------------------------ void WindowBox::Reset () { m_locked = false; // Find the amount to convert from relative- to screen coordinates // Do this by finding the parent of the element (until no parent) const CEGUI::Rect winRc = m_boxedWindow->getUnclippedPixelRect(); // Make boxes 3x3 and always in pixels //int width = 7; //int height = 7; const int paddX = 3; const int paddY = 3; // Position the "TopLeft" resizer m_resizePoints [RESIZE_POINT_WN].d_left = winRc.d_left - paddX; m_resizePoints [RESIZE_POINT_WN].d_top = winRc.d_top - paddY; // Position the "Top" resizer m_resizePoints [RESIZE_POINT_N].d_left = winRc.d_left + winRc.getWidth() / 2 - paddX; m_resizePoints [RESIZE_POINT_N].d_top = winRc.d_top - paddY; // Position the "TopRight" resizer m_resizePoints [RESIZE_POINT_NE].d_left = winRc.d_left + winRc.getWidth() - paddX; m_resizePoints [RESIZE_POINT_NE].d_top = winRc.d_top - paddY; // Position the "Right" resizer m_resizePoints [RESIZE_POINT_E].d_left = winRc.d_left + winRc.getWidth() - paddX; m_resizePoints [RESIZE_POINT_E].d_top = winRc.d_top + winRc.getHeight() / 2 - paddY; // Position the "BottomRight" resizer m_resizePoints [RESIZE_POINT_ES].d_left = winRc.d_left + winRc.getWidth() - paddX; m_resizePoints [RESIZE_POINT_ES].d_top = winRc.d_top + winRc.getHeight() - paddY; // Position the "Bottom" resizer m_resizePoints [RESIZE_POINT_S].d_left = winRc.d_left + winRc.getWidth() / 2 - paddX; m_resizePoints [RESIZE_POINT_S].d_top = winRc.d_top + winRc.getHeight() - paddY; // Position the "BottomLeft" resizer m_resizePoints [RESIZE_POINT_SW].d_left = winRc.d_left - paddX; m_resizePoints [RESIZE_POINT_SW].d_top = winRc.d_top + winRc.getHeight() - paddY; // Position the "Left" resizer m_resizePoints [RESIZE_POINT_W].d_left = winRc.d_left - paddX; m_resizePoints [RESIZE_POINT_W].d_top = winRc.d_top + winRc.getHeight() / 2 - paddY; for (int i = 0; i < NUM_RESIZE_POINTS; ++i) { m_resizePoints [i].d_right = m_resizePoints [i].d_left + (paddX * 2.0f) ; m_resizePoints [i].d_bottom = m_resizePoints [i].d_top + (paddY * 2.0f) ; } }
void CUIEditorView::setWindowSelected(const CEGUI::String& name,bool addEvent /*= true*/) { try { if( name.length()> 0 && name != m_nSelectWindowName) { if(name == "___Shower_Window____") return; CEGUI::Window* pWindow = CEGUI::WindowManager::getSingleton().getWindow(name); CEGUI::Window* pOldSel = NULL; if (pWindow && !pWindow->isAutoWindow()) { if(m_nSelectWindowName.length() > 0) { pOldSel = CEGUI::WindowManager::getSingleton().getWindow(m_nSelectWindowName); if (pOldSel) { for(;pOldSel && pOldSel != CEGUI::System::getSingleton().getGUISheet(); pOldSel = pOldSel->getParent()) { pOldSel->unsubscribeEvent(CEGUI::Window::EventMoved, CEGUI::Event::Subscriber(&CUIEditorView::handleSelectedWindowMoved, this)); } } } //pWindow->moveToFront(); m_nSelectWindowName = pWindow->getName(); CEGUI::Window* pSet = pWindow; for (; pSet&& pSet !=CEGUI::System::getSingleton().getGUISheet(); pSet = pSet->getParent() ) { pSet->subscribeEvent(CEGUI::Window::EventMoved, CEGUI::Event::Subscriber(&CUIEditorView::handleSelectedWindowMoved, this)); } CEGUI::Rect rect = pWindow->getPixelRect(); setSelectWindowPos(CRect(rect.d_left, rect.d_top, rect.getWidth(), rect.getHeight())); m_ptMouseMovePos = CPoint(0,0); } m_pSelectedWindow = pWindow; updateCurrentWindowStatusText(); if (addEvent) { g_DataPool.OnSelectWindowChanged(pOldSel,pWindow); } } else if (name.length() == 0) { if (addEvent) { g_DataPool.OnSelectWindowChanged(m_pSelectedWindow,NULL); } m_nSelectWindowName = ""; setSelectWindowPos(CRect(), true); m_pSelectedWindow = NULL; } } catch(CEGUI::UnknownObjectException& e) { } }
bool CUIEditorView::handleSelectedWindowMoved(const CEGUI::EventArgs &e) { if(m_pSelectedWindow) { CEGUI::Rect rect = m_pSelectedWindow->getPixelRect(); setSelectWindowPos(CRect(rect.d_left, rect.d_top, rect.getWidth(), rect.getHeight())); updateCurrentWindowStatusText(); GetRightPropList()->UpdateBasePosAndSizeProperty(m_pSelectedWindow); return true; } return false; }
void CUIEditorView::updateCurrentWindowStatusText(void) { if (m_pSelectedWindow) { CHAR szText[MAX_PATH] = {0}; CEGUI::Rect rect = m_pSelectedWindow->getRect(CEGUI::Absolute); sprintf(szText, "当前窗口:%s 位置:(%d,%d) 大小:(%d,%d)",m_pSelectedWindow->getName().c_str(), (INT)rect.getPosition().d_x,(INT)rect.getPosition().d_y, (INT)rect.getWidth(), (INT)rect.getHeight()); ((CMainFrame*)AfxGetMainWnd())->SetStatusText(2,szText); sprintf(szText, "当前窗口类型:%s",m_pSelectedWindow->getWidgetType().c_str()); ((CMainFrame*)AfxGetMainWnd())->SetStatusText(3,szText); } }
//------------------------------------------------------------------------ void SelectionMover::MoveUsingScale(const CEGUI::Window* const window, CEGUI::URect& windowArea, const float left, const float top, const float right, const float bottom) const { // Validations wxASSERT_MSG(window != NULL, wxT("Supplied window is NULL")); // Calculate relative versions of the given values const float renderWidth = CEGUI::System::getSingleton().getRenderer()->getDisplaySize().d_width; const float renderHeight = CEGUI::System::getSingleton().getRenderer()->getDisplaySize().d_height; // We need to know how much 1 pixel means relatively for the current resolution float scaleDeltaLeft = left / renderWidth; float scaleDeltaTop = top / renderHeight; float scaleDeltaRight = right / renderWidth; float scaleDeltaBottom = bottom / renderHeight; CEGUI::Rect windowRect; if (window->getParent()) { windowRect = CEGUI::CoordConverter::windowToScreen(*window->getParent(), windowArea); // Pixels } else { windowRect = CEGUI::CoordConverter::windowToScreen(*window, windowArea); // Pixels } // Avoid negative widths and heights if (windowRect.getWidth() + (right - left) > 1.0f && windowRect.getHeight() + (bottom - top) > 1.0f) { const CEGUI::Window* parent = window->getParent(); while (parent) { // Update relative values when a parent is set. // When a parent is set, make the difference relatively larger. if (parent->getWidth().d_scale) scaleDeltaLeft /= parent->getWidth().d_scale; if (parent->getHeight().d_scale) scaleDeltaTop /= parent->getHeight().d_scale; if (parent->getWidth().d_scale) scaleDeltaRight /= parent->getWidth().d_scale; if (parent->getHeight().d_scale) scaleDeltaBottom /= parent->getHeight().d_scale; // next parent = parent->getParent(); } // In UDim land, there is no metrics mode anymore. // Only update the 'scale' part. The 'offset' part can only // be changed from the property grid in the main dialog. // Left windowArea.d_min.d_x.d_scale += scaleDeltaLeft; // Top windowArea.d_min.d_y.d_scale += scaleDeltaTop; // Right windowArea.d_max.d_x.d_scale += scaleDeltaRight; // Bottom windowArea.d_max.d_y.d_scale += scaleDeltaBottom; } }