/*! * This method sets the height and width of the preview from * the size of the comment in the annotation. */ void AP_Preview_Annotation::setSizeFromAnnotation(void) { FV_View * pView = static_cast<FV_View *>(getActiveFrame()->getCurrentView()); GR_Graphics * pG = NULL; UT_return_if_fail(pView); pG = pView->getGraphics(); UT_return_if_fail(pG); GR_Font * pFont = pG->findFont("Times New Roman", "normal", "normal", "normal", "normal", "12pt", NULL); UT_return_if_fail(pFont); double rat = 100./static_cast<double>(pG->getZoomPercentage()); UT_sint32 iHeight = pG->getFontAscent(pFont) + pG->tlu(7); iHeight = static_cast<UT_sint32>(static_cast<double>(iHeight)); m_drawString = m_sDescription; UT_sint32 len = m_drawString.size(); pG->setFont(pFont); UT_sint32 iwidth = pG->measureString(m_drawString.ucs4_str(),0,len,NULL) + pG->tlu(6); iwidth = static_cast<UT_sint32>(static_cast<double>(iwidth)); m_width = static_cast<UT_sint32>(static_cast<double>(pG->tdu(iwidth))*rat); m_height = static_cast<UT_sint32>(static_cast<double>(pG->tdu(iHeight))*rat); if(pG->tdu(pView->getWindowWidth()) < m_width) m_width = pG->tdu(pView->getWindowWidth()); UT_DEBUGMSG(("SetSize from Annotation width %d rat %f \n",m_width,rat)); }
void FV_VisualDragText::_actuallyScroll(UT_Worker * pWorker) { UT_return_if_fail(pWorker); // this is a static callback method and does not have a 'this' pointer. FV_VisualDragText * pVis = static_cast<FV_VisualDragText *>(pWorker->getInstanceData()); UT_return_if_fail(pVis); FV_View * pView = pVis->m_pView; pVis->getGraphics()->setClipRect(&pVis->m_recCurFrame); pView->updateScreen(false); pView->getGraphics()->setClipRect(NULL); bool bScrollDown = false; bool bScrollUp = false; bool bScrollLeft = false; bool bScrollRight = false; UT_sint32 y = pVis->m_yLastMouse; UT_sint32 x = pVis->m_xLastMouse; if(y<=0) { bScrollUp = true; } else if(y >= pView->getWindowHeight()) { bScrollDown = true; } if(x <= 0) { bScrollLeft = true; } else if(x >= pView->getWindowWidth()) { bScrollRight = true; } if(bScrollDown || bScrollUp || bScrollLeft || bScrollRight) { UT_sint32 minScroll = pView->getGraphics()->tlu(20); if(bScrollUp) { UT_sint32 yscroll = abs(y); if(yscroll < minScroll) yscroll = minScroll; pView->cmdScroll(AV_SCROLLCMD_LINEUP, static_cast<UT_uint32>( yscroll) + iExtra); } else if(bScrollDown) { UT_sint32 yscroll = y - pView->getWindowHeight(); if(yscroll < minScroll) yscroll = minScroll; pView->cmdScroll(AV_SCROLLCMD_LINEDOWN, static_cast<UT_uint32>(yscroll) + iExtra); } if(bScrollLeft) { pView->cmdScroll(AV_SCROLLCMD_LINELEFT, static_cast<UT_uint32>(-x)); } else if(bScrollRight) { pView->cmdScroll(AV_SCROLLCMD_LINERIGHT, static_cast<UT_uint32>(x -pView->getWindowWidth())); } pVis->drawImage(); #if 0 PT_DocPosition posAtXY = pVis->getPosFromXY(x,y); pView->_setPoint(posAtXY); pVis->drawCursor(posAtXY); #endif iExtra = 0; return; } else { if(pVis->m_pAutoScrollTimer) pVis->m_pAutoScrollTimer->stop(); DELETEP(pVis->m_pAutoScrollTimer); } s_pScroll->stop(); delete s_pScroll; s_pScroll = NULL; bScrollRunning = false; iExtra = 0; }