void LineItem::updateChildGeometry(const QRectF &oldParentRect, const QRectF &newParentRect) { // parent has been resized: update the line's dimensions: // we would like to have lines in terms of relative endpoint locations, // but instead they are in terms of length (relative to parent width) // and angle, relative to the parent. qreal theta = rotationAngle()*M_PI/180.0; qreal oldL = relativeWidth()*oldParentRect.width(); // we want to keep the endpoints fixed relative to the parent, so // we need to calculate new lengths and angles. qreal newDx = cos(theta)*oldL*newParentRect.width()/oldParentRect.width(); qreal newDy = sin(theta)*oldL*newParentRect.height()/oldParentRect.height(); qreal newWidth = sqrt(newDx*newDx + newDy*newDy); QTransform transform; transform.rotate(atan2(newDy, newDx)*180.0/M_PI); // my brain hurts less for rotations when we center the object at 0,0 QRectF itemRect(-newWidth*0.5, -rect().height()*0.5, newWidth, rect().height()); // we don't now what the parents's origin is, so, add .x() and .y() setPos(relativeCenter().x() * newParentRect.width() + newParentRect.x(), relativeCenter().y() * newParentRect.height()+ newParentRect.y()); setViewRect(itemRect, true); setTransform(transform); setRelativeWidth(newWidth / newParentRect.width()); }
void CMainFrame::OnSize(UINT nType, int cx, int cy) { __super::OnSize(nType, cx, cy); if(IsIconic()) { return; } TextView *view1 = getActiveTextView(); TextView *view2 = view1 ? view1->getPartner() : NULL; if(view1) view1->savePositionState(); if(view2) view2->savePositionState(); if(m_wndSplitter.IsWindowVisible()) { m_wndSplitter.SetScrollStyle(0); setRelativeWidth(cx); m_wndSplitter.SetScrollStyle(0); m_wndSplitter.RecalcLayout(); // m_wndSplitter.GetPane(0,0)->ShowScrollBar(SB_BOTH,FALSE); // m_wndSplitter.GetPane(0,0)->ShowScrollBar(SB_BOTH,FALSE); getOptions().m_windowSize = getWindowSize(this); } }