UT_Error IE_Exp_EPUB::doOptions() { XAP_Frame * pFrame = XAP_App::getApp()->getLastFocussedFrame(); if (!pFrame || isCopying()) return UT_OK; if (pFrame) { AV_View * pView = pFrame->getCurrentView(); if (pView) { GR_Graphics * pG = pView->getGraphics(); if (pG && pG->queryProperties(GR_Graphics::DGP_PAPER)) { return UT_OK; } } } //FIXME:FIDENCIO: Remove this clause when Cocoa's dialog is implemented #ifdef TOOLKIT_COCOA return UT_OK; #else /* run the dialog */ XAP_Dialog_Id id = m_iDialogExport; XAP_DialogFactory * pDialogFactory = static_cast<XAP_DialogFactory *> (XAP_App::getApp()->getDialogFactory()); AP_Dialog_EpubExportOptions* pDialog = static_cast<AP_Dialog_EpubExportOptions*> (pDialogFactory->requestDialog(id)); if (pDialog == NULL) { return UT_OK; } pDialog->setEpubExportOptions(&m_exp_opt, XAP_App::getApp()); pDialog->runModal(pFrame); /* extract what they did */ bool bSave = pDialog->shouldSave(); pDialogFactory->releaseDialog(pDialog); if (!bSave) { return UT_SAVE_CANCELLED; } return UT_OK; #endif }
void AP_UnixFrame::setYScrollRange(void) { AP_UnixFrameImpl * pFrameImpl = static_cast<AP_UnixFrameImpl *>(getFrameImpl()); UT_return_if_fail(pFrameImpl); GR_Graphics * pGr = pFrameImpl->getFrame ()->getCurrentView ()->getGraphics (); int height = 0; if(m_pData) //this isn't guaranteed in AbiCommand height = static_cast<AP_FrameData*>(m_pData)->m_pDocLayout->getHeight(); int windowHeight = 0; GtkAllocation allocation; gtk_widget_get_allocation(GTK_WIDGET(pFrameImpl->m_dArea),&allocation); if(pFrameImpl->m_dArea) //this isn't guaranteed in AbiCommand windowHeight = static_cast<int>(pGr->tluD (allocation.height)); int newvalue = ((m_pView) ? m_pView->getYScrollOffset() : 0); int newmax = height - windowHeight; /* upper - page_size */ if (newmax <= 0) newvalue = 0; else if (newvalue > newmax) newvalue = newmax; bool bDifferentPosition = false; UT_sint32 diff = 0; if(pFrameImpl->m_pVadj) //this isn't guaranteed in AbiCommand { bDifferentPosition = (newvalue != static_cast<UT_sint32>(gtk_adjustment_get_value(pFrameImpl->m_pVadj) +0.5)); diff = static_cast<UT_sint32>(gtk_adjustment_get_upper(pFrameImpl->m_pVadj)- gtk_adjustment_get_page_size(pFrameImpl->m_pVadj) +0.5); } if(bDifferentPosition) { UT_sint32 iDU = pGr->tdu( static_cast<UT_sint32>(gtk_adjustment_get_value(pFrameImpl->m_pVadj) +0.5) - newvalue); if(iDU == 0) { bDifferentPosition = false; gtk_adjustment_set_value(pFrameImpl->m_pVadj, static_cast<gdouble>(newvalue)); } } bool bDifferentLimits = ((height-windowHeight) != diff); if (m_pView && (bDifferentPosition || bDifferentLimits)) { pFrameImpl->_setScrollRange(apufi_scrollY, newvalue, static_cast<gfloat>(height), static_cast<gfloat>(windowHeight)); m_pView->sendVerticalScrollEvent(newvalue, static_cast<UT_sint32> (gtk_adjustment_get_upper(pFrameImpl->m_pVadj) - gtk_adjustment_get_page_size(pFrameImpl->m_pVadj))); } }
void XAP_CustomWidgetLU::draw(const UT_Rect *clip) { GR_Graphics *gr = getGraphics(); UT_ASSERT(gr); if (clip == NULL) drawLU(NULL); else { UT_Rect r( gr->tlu(clip->left), gr->tlu(clip->top), gr->tlu(clip->width), gr->tlu(clip->height) ); drawLU(&r); } }
bool Presentation::start(AV_View * view) { EV_EditMethodContainer * pEMC = m_pApp->getEditMethodContainer(); g_return_val_if_fail (pEMC != 0, FALSE); m_pView = static_cast<FV_View *>(view); m_sPrevBindings = m_pApp->getInputMode(); _loadPresentationBindings(view); UT_sint32 i = m_pApp->setInputMode("Presentation"); if(i < 0 ) return false; // get a handle to the actual EditMethod EV_EditMethod * pFullScreen = pEMC->findEditMethodByName ("viewFullScreen"); g_return_val_if_fail (pFullScreen != 0, false); const char * sz =""; EV_EditMethodCallData calldata(sz,0); calldata.m_xPos = 0; calldata.m_yPos = 0; m_iPage = 0; XAP_Frame * pFrame = static_cast<XAP_Frame*>(m_pView->getParentData()); m_OldZoomType = pFrame->getZoomType(); m_iOldZoom = pFrame->getZoomPercentage(); pFrame->hideMenuScroll(true); bool b = false; b = (pFullScreen->Fn(view,&calldata) ? TRUE : FALSE); GR_Graphics * pG = m_pView->getGraphics(); // // Let all the configure events propagate to their full extent // for(i= 0; i<20;i++) pFrame->nullUpdate(); pFrame->setZoomType(XAP_Frame::z_PAGEWIDTH); i = m_pView-> calculateZoomPercentForPageWidth(); pFrame->quickZoom(i); for(i= 0; i<20;i++) pFrame->nullUpdate(); b= showNextPage(); if(pG) pG->allCarets()->disable(); return b; }
static bool Presentation_context (AV_View * v, EV_EditMethodCallData * d) { FV_View * pView = static_cast<FV_View *>(v); XAP_Frame * pFrame = static_cast<XAP_Frame *> (pView->getParentData()); UT_sint32 xPos = d->m_xPos; UT_sint32 yPos = d->m_yPos; const char * szContextMenuName = XAP_App::getApp()->getMenuFactory()->FindContextMenu(PresentationContextID); UT_DEBUGMSG(("Context Menu Name is........ %s \n",szContextMenuName)); if (!szContextMenuName) return false; bool res = pFrame->runModalContextMenu(pView,szContextMenuName, xPos,yPos); pFrame->nullUpdate(); GR_Graphics * pG = pView->getGraphics(); if(pG) pG->allCarets()->disable(); return res; }
/*! * Draw the frame handles */ void fp_FrameContainer::drawHandles(dg_DrawArgs * pDA) { if(getView() == NULL) { getSectionLayout()->format(); getSectionLayout()->setNeedsReformat(getSectionLayout()); } if(getView() == NULL) { return; } if(!getPage()) { return; } // // Only fill to the bottom of the viewed page. // GR_Graphics * pG = pDA->pG; UT_sint32 iFullHeight = getFullHeight(); fl_DocSectionLayout * pDSL = getDocSectionLayout(); UT_sint32 iMaxHeight = 0; if(!pG->queryProperties(GR_Graphics::DGP_PAPER) && (getView()->getViewMode() != VIEW_PRINT)) { iMaxHeight = pDSL->getActualColumnHeight(); } else { iMaxHeight = getPage()->getHeight(); } UT_sint32 iBot = getFullY()+iFullHeight; if(iBot > iMaxHeight) { iFullHeight = iFullHeight - (iBot-iMaxHeight); } UT_sint32 iXlow = pDA->xoff - m_iXpad; UT_sint32 iYlow = pDA->yoff - m_iYpad; UT_Rect box(iXlow + pDA->pG->tlu(2), iYlow + pDA->pG->tlu(2), getFullWidth() - pDA->pG->tlu(4), iFullHeight - pDA->pG->tlu(4)); getPage()->expandDamageRect(box.left,box.top,box.width,box.height); getView()->drawSelectionBox(box, true); }
gint AP_UnixLeftRuler::_fe::expose(GtkWidget * w, GdkEventExpose* pExposeEvent) { // a static function AP_UnixLeftRuler * pUnixLeftRuler = static_cast<AP_UnixLeftRuler *>(g_object_get_data(G_OBJECT(w), "user_data")); if (!pUnixLeftRuler) return 0; GR_Graphics * pG = pUnixLeftRuler->getGraphics(); if(pG != NULL) { UT_Rect rClip; rClip.left = pG->tlu(pExposeEvent->area.x); rClip.top = pG->tlu(pExposeEvent->area.y); rClip.width = pG->tlu(pExposeEvent->area.width); rClip.height = pG->tlu(pExposeEvent->area.height); pUnixLeftRuler->draw(&rClip); } return 0; }
void AP_UnixFrame::setXScrollRange(void) { AP_UnixFrameImpl * pFrameImpl = static_cast<AP_UnixFrameImpl *>(getFrameImpl()); UT_return_if_fail(pFrameImpl); GR_Graphics * pGr = pFrameImpl->getFrame ()->getCurrentView ()->getGraphics (); int width = 0; if(m_pData) //this isn't guaranteed in AbiCommand width = static_cast<AP_FrameData*>(m_pData)->m_pDocLayout->getWidth(); int windowWidth = 0; GtkAllocation allocation; gtk_widget_get_allocation(GTK_WIDGET(pFrameImpl->m_dArea),&allocation); if(pFrameImpl->m_dArea) //this isn't guaranteed in AbiCommand windowWidth = static_cast<int>(pGr->tluD (allocation.width)); int newvalue = ((m_pView) ? m_pView->getXScrollOffset() : 0); int newmax = width - windowWidth; /* upper - page_size */ if (newmax <= 0) newvalue = 0; else if (newvalue > newmax) newvalue = newmax; bool bDifferentPosition = false; bool bDifferentLimits = false; if(pFrameImpl->m_pHadj) //this isn't guaranteed in AbiCommand { bDifferentPosition = (newvalue != gtk_adjustment_get_value(pFrameImpl->m_pHadj)); bDifferentLimits = ((width-windowWidth) != gtk_adjustment_get_upper(pFrameImpl->m_pHadj)- gtk_adjustment_get_page_size(pFrameImpl->m_pHadj)); } pFrameImpl->_setScrollRange(apufi_scrollX, newvalue, static_cast<gfloat>(width), static_cast<gfloat>(windowWidth)); if (m_pView && (bDifferentPosition || bDifferentLimits)) m_pView->sendHorizontalScrollEvent(newvalue, static_cast<UT_sint32> (gtk_adjustment_get_upper(pFrameImpl->m_pHadj)- gtk_adjustment_get_page_size(pFrameImpl->m_pHadj))); }
bool Presentation::drawNthPage(UT_sint32 iPage) { GR_Graphics * pG = m_pView->getGraphics(); GR_Painter p(pG); #if USE_PIXMAP GR_Image * pImage = renderPageToImage(iPage,pG->getZoomPercentage()); UT_DEBUGMSG(("Image Display Width %d Image Display Height %d Zoom %d \n",pImage->getDisplayWidth(),pImage->getDisplayHeight(),pG->getZoomPercentage())); p.drawImage(pImage,0,0); delete pImage; #else dg_DrawArgs da; da.pG = pG; da.xoff = 0; da.yoff = 0; m_pView->draw(iPage, &da); fp_Page * pPage = m_pView->getLayout()->getNthPage(iPage); UT_sint32 iTotalHeight = (pPage->getHeight() + m_pView->getPageViewSep())*iPage; m_pView->setYScrollOffset(iTotalHeight); if(pG) pG->allCarets()->disable(); #endif return true; }
void AP_UnixFrameImpl::_setScrollRange(apufi_ScrollType scrollType, int iValue, gfloat fUpperLimit, gfloat fSize) { GtkAdjustment *pScrollAdjustment = (scrollType == apufi_scrollX) ? m_pHadj : m_pVadj; GtkWidget *wScrollWidget = (scrollType == apufi_scrollX) ? m_hScroll : m_vScroll; UT_DEBUGMSG(("Scroll Adjustment set to %d upper %f size %f\n",iValue, fUpperLimit, fSize)); GR_Graphics * pGr = getFrame()->getCurrentView()->getGraphics (); XAP_Frame::tZoomType tZoom = getFrame()->getZoomType(); if(pScrollAdjustment) //this isn't guaranteed in AbiCommand { #if GTK_CHECK_VERSION(2,14,0) gtk_adjustment_configure(pScrollAdjustment, iValue, 0.0, fUpperLimit, pGr->tluD(20.0), fSize, fSize); #else pScrollAdjustment->value = iValue; pScrollAdjustment->lower = 0.0; pScrollAdjustment->upper = fUpperLimit; pScrollAdjustment->step_increment = pGr->tluD(20.0); pScrollAdjustment->page_increment = fSize; pScrollAdjustment->page_size = fSize; g_signal_emit_by_name(G_OBJECT(pScrollAdjustment), "changed"); #endif } // hide the horizontal scrollbar if the scroll range is such that the window can contain it all // show it otherwise // Hide the horizontal scrollbar if we've set to page width or fit to page. // This stops a resizing race condition. // if ((m_hScroll == wScrollWidget) && ((fUpperLimit <= fSize) ||( tZoom == XAP_Frame::z_PAGEWIDTH) || (tZoom == XAP_Frame::z_WHOLEPAGE))) { gtk_widget_hide(wScrollWidget); } else if((wScrollWidget != m_vScroll) || !getFrame()->isMenuScrollHidden()) { gtk_widget_show(wScrollWidget); } }
/*! * Draw the frame boundaries */ void fp_FrameContainer::drawBoundaries(dg_DrawArgs * pDA) { UT_sint32 iXlow = pDA->xoff - m_iXpad; UT_sint32 iXhigh = iXlow + getFullWidth() ; UT_sint32 iYlow = pDA->yoff - m_iYpad; UT_sint32 iYhigh = iYlow + getFullHeight(); GR_Graphics * pG = pDA->pG; if(getPage()) { getPage()->expandDamageRect(iXlow,iYlow,getFullWidth(),getFullHeight()); // // Only fill to the bottom of the viewed page. // UT_sint32 iFullHeight = getFullHeight(); fl_DocSectionLayout * pDSL = getDocSectionLayout(); UT_sint32 iMaxHeight = 0; if(!pG->queryProperties(GR_Graphics::DGP_PAPER) && (getView()->getViewMode() != VIEW_PRINT)) { iMaxHeight = pDSL->getActualColumnHeight(); } else { iMaxHeight = getPage()->getHeight(); } UT_sint32 iBot = getFullY()+iFullHeight; if(iBot > iMaxHeight) { iFullHeight = iFullHeight - (iBot-iMaxHeight); iYhigh = iFullHeight; } } _drawLine(m_lineTop,iXlow,iYlow,iXhigh,iYlow,pDA->pG); // top _drawLine(m_lineRight,iXhigh,iYlow,iXhigh,iYhigh,pDA->pG); // right _drawLine(m_lineBottom,iXlow,iYhigh,iXhigh,iYhigh,pDA->pG); // bottom _drawLine(m_lineLeft,iXlow,iYlow,iXlow,iYhigh,pDA->pG); // left }
void fp_AnnotationRun::_draw(dg_DrawArgs* pDA) { if(!displayAnnotations()) return; if(!m_bIsStart) return; GR_Graphics * pG = pDA->pG; UT_sint32 xoff = 0, yoff = 0; GR_Painter painter(pG); // need screen locations of this run getLine()->getScreenOffsets(this, xoff, yoff); UT_sint32 iYdraw = pDA->yoff - getAscent()-1; UT_uint32 iRunBase = getBlock()->getPosition() + getBlockOffset(); // // Sevior was here // UT_sint32 iFillTop = iYdraw; UT_sint32 iFillTop = iYdraw+1; UT_sint32 iFillHeight = getAscent() + getDescent(); FV_View* pView = _getView(); UT_uint32 iSelAnchor = pView->getSelectionAnchor(); UT_uint32 iPoint = pView->getPoint(); UT_uint32 iSel1 = UT_MIN(iSelAnchor, iPoint); UT_uint32 iSel2 = UT_MAX(iSelAnchor, iPoint); UT_ASSERT(iSel1 <= iSel2); bool bIsInTOC = getBlock()->isContainedByTOC(); if ( isInSelectedTOC() || (!bIsInTOC && ( /* pView->getFocus()!=AV_FOCUS_NONE && */ (iSel1 <= iRunBase) && (iSel2 > iRunBase))) ) { UT_RGBColor color(_getView()->getColorSelBackground()); pG->setColor(_getView()->getColorAnnotation(this)); painter.fillRect(color, pDA->xoff, iFillTop, getWidth(), iFillHeight); } else { Fill(getGraphics(),pDA->xoff, iFillTop, getWidth(), iFillHeight); pG->setColor(_getColorFG()); } pG->setFont(_getFont()); pG->setColor(_getView()->getColorAnnotation(this)); UT_DEBUGMSG(("Drawing string m_sValue %s \n",m_sValue.utf8_str())); painter.drawChars(m_sValue.ucs4_str().ucs4_str(), 0,m_sValue.ucs4_str().size(), pDA->xoff,iYdraw, NULL); // // Draw underline/overline/strikethough // UT_sint32 yTopOfRun = pDA->yoff - getAscent()-1; // Hack to remove //character dirt drawDecors( xoff, yTopOfRun,pG); }
/*! * 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)); }
/*! * Background abi repaint function. \param XAP_UnixFrame * p pointer to the Frame that initiated this background repainter. */ gint AP_UnixLeftRuler::_fe::abi_expose_repaint( gpointer p) { // // Grab our pointer so we can do useful stuff. // UT_Rect localCopy; AP_UnixLeftRuler * pR = static_cast<AP_UnixLeftRuler *>(p); GR_Graphics * pG = pR->getGraphics(); if(pG == NULL || pG->isDontRedraw()) { // // Come back later // return TRUE; } FV_View * pView = static_cast<FV_View *>(pR->m_pFrame->getCurrentView()); if(pView && pView->getPoint()==0) { // // Come back later // return TRUE; } pG->setSpawnedRedraw(true); if(pG->isExposePending()) { while(pG->isExposedAreaAccessed()) { UT_usleep(10); // 10 microseconds } pG->setExposedAreaAccessed(true); localCopy.set(pG->getPendingRect()->left,pG->getPendingRect()->top, pG->getPendingRect()->width,pG->getPendingRect()->height); // // Clear out this set of expose info // pG->setExposePending(false); pG->setExposedAreaAccessed(false); xxx_UT_DEBUGMSG(("Painting area on Left ruler: left=%d, top=%d, width=%d, height=%d\n", localCopy.left, localCopy.top, localCopy.width, localCopy.height)); xxx_UT_DEBUGMSG(("SEVIOR: Repaint now \n")); pR->draw(&localCopy); } // // OK we've finshed. Wait for the next signal // pG->setSpawnedRedraw(false); return TRUE; }
/*! * Import graphic for cell background. */ void AP_Dialog_FormatTable::askForGraphicPathName(void) { XAP_Frame * pFrame = XAP_App::getApp()->getLastFocussedFrame(); UT_return_if_fail(pFrame); XAP_DialogFactory * pDialogFactory = static_cast<XAP_DialogFactory *>(pFrame->getDialogFactory()); UT_return_if_fail(pDialogFactory); XAP_Dialog_FileOpenSaveAs * pDialog = static_cast<XAP_Dialog_FileOpenSaveAs *>(pDialogFactory->requestDialog(XAP_DIALOG_ID_INSERT_PICTURE)); UT_return_if_fail (pDialog); pDialog->setCurrentPathname(NULL); pDialog->setSuggestFilename(false); // to fill the file types popup list, we need to convert AP-level // ImpGraphic descriptions, suffixes, and types into strings. UT_uint32 filterCount = IE_ImpGraphic::getImporterCount(); const char ** szDescList = static_cast<const char **>(UT_calloc(filterCount + 1, sizeof(char *))); const char ** szSuffixList = static_cast<const char **>(UT_calloc(filterCount + 1, sizeof(char *))); IEGraphicFileType * nTypeList = (IEGraphicFileType *) UT_calloc(filterCount + 1, sizeof(IEGraphicFileType)); UT_uint32 k = 0; while (IE_ImpGraphic::enumerateDlgLabels(k, &szDescList[k], &szSuffixList[k], &nTypeList[k])) k++; pDialog->setFileTypeList(szDescList, szSuffixList, static_cast<const UT_sint32 *>(nTypeList)); pDialog->runModal(pFrame); XAP_Dialog_FileOpenSaveAs::tAnswer ans = pDialog->getAnswer(); bool bOK = (ans == XAP_Dialog_FileOpenSaveAs::a_OK); if (bOK) { m_sImagePath = pDialog->getPathname(); UT_sint32 type = pDialog->getFileType(); // If the number is negative, it's a special type. // Some operating systems which depend solely on filename // suffixes to identify type (like Windows) will always // want auto-detection. if (type < 0) switch (type) { case XAP_DIALOG_FILEOPENSAVEAS_FILE_TYPE_AUTO: // do some automagical detecting m_iGraphicType = IEGFT_Unknown; break; default: // it returned a type we don't know how to handle UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN); } else m_iGraphicType = static_cast<IEGraphicFileType>(pDialog->getFileType()); } FREEP(szDescList); FREEP(szSuffixList); FREEP(nTypeList); pDialogFactory->releaseDialog(pDialog); if(m_sImagePath.size() == 0) { return; } FG_Graphic* pFG = NULL; UT_Error errorCode; errorCode = IE_ImpGraphic::loadGraphic(m_sImagePath.c_str(), m_iGraphicType, &pFG); if(errorCode != UT_OK || !pFG) { ShowErrorBox(m_sImagePath, errorCode); return; } DELETEP(m_pGraphic); DELETEP(m_pImage); m_pGraphic = pFG->clone(); GR_Graphics * pG = m_pFormatTablePreview->getGraphics(); FV_View * pView = static_cast<FV_View *>(pFrame->getCurrentView()); UT_return_if_fail(pView && pView->getDocument()); UT_uint32 uid = pView->getDocument()->getUID(UT_UniqueId::Image); //see Bug 10852 m_sImagePath.clear(); UT_String_sprintf(m_sImagePath,"%d",uid); const UT_ByteBuf * pBB = m_pGraphic->getBuffer(); if(m_pGraphic->getType() == FGT_Raster) { m_pImage = static_cast<GR_Image *>( pG->createNewImage( m_sImagePath.c_str(), pBB, pFG->getMimeType(), pFG->getWidth(), pFG->getHeight(), GR_Image::GRT_Raster)); } else { m_pImage = static_cast<GR_Image *>( pG->createNewImage( m_sImagePath.c_str(), pBB, pFG->getMimeType(), m_pFormatTablePreview->getWindowWidth()-2, m_pFormatTablePreview->getWindowHeight()-2, GR_Image::GRT_Vector)); } // draw the preview with the changed properties if(m_pFormatTablePreview) m_pFormatTablePreview->queueDraw(); }
/*! Draw container content \param pDA Draw arguments */ void fp_FrameContainer::draw(dg_DrawArgs* pDA) { FV_View * pView = getView(); UT_return_if_fail( pView); xxx_UT_DEBUGMSG(("FrameContainer %x called, page %x \n",this,getPage())); if(getPage() == NULL) { getSectionLayout()->format(); getSectionLayout()->setNeedsReformat(getSectionLayout()); if(getPage() == NULL) { return; } } if(pView) { if(pView->getFrameEdit()->getFrameEditMode() == FV_FrameEdit_DRAG_EXISTING) { if((pView->getFrameEdit()->getFrameContainer() == this)) { return; } } } // // Only draw the lines in the clipping region. // /* [Somewhere down here is where the logic to only draw the region of the frame which is within the complement of the union of all higher frames needs to be. We need to draw the applicable region of the rectangle we're on, then unify it with (if applicable) the higher union.] <-- Possibly obsolete comment, not sure. I think I might have landed on an alternative solution involving more rearranging of the storage of the FrameContainers, based on their z-index. Not sure how far I got with that or if it worked either. See also abi bug 7664 and the original discussions about defining the undefinedness of layered frame behaviour. */ if(m_bOverWrote) { pDA->bDirtyRunsOnly = false; } dg_DrawArgs da = *pDA; GR_Graphics * pG = da.pG; UT_return_if_fail( pG); UT_sint32 x = pDA->xoff - m_iXpad; UT_sint32 y = pDA->yoff - m_iYpad; getPage()->expandDamageRect(x,y,getFullWidth(),getFullHeight()); if(!pDA->bDirtyRunsOnly || m_bNeverDrawn) { if(m_bNeverDrawn) { pDA->bDirtyRunsOnly= false; } UT_sint32 srcX,srcY; getSectionLayout()->checkGraphicTick(pG); srcX = -m_iXpad; srcY = -m_iYpad; // // Only fill to the bottom of the viewed page. // UT_sint32 iFullHeight = getFullHeight(); fl_DocSectionLayout * pDSL = getDocSectionLayout(); UT_sint32 iMaxHeight = 0; if(!pG->queryProperties(GR_Graphics::DGP_PAPER) && (pView->getViewMode() != VIEW_PRINT)) { iMaxHeight = pDSL->getActualColumnHeight(); } else { iMaxHeight = getPage()->getHeight(); } UT_sint32 iBot = getFullY()+iFullHeight; if(iBot > iMaxHeight) { iFullHeight = iFullHeight - (iBot-iMaxHeight); } getFillType()->Fill(pG,srcX,srcY,x,y,getFullWidth(),iFullHeight); m_bNeverDrawn = false; } UT_uint32 count = countCons(); UT_DEBUGMSG(("Number of containers in frame %d \n",count)); const UT_Rect * pPrevRect = pDA->pG->getClipRect(); UT_Rect * pRect = getScreenRect(); UT_Rect newRect; bool bRemoveRectAfter = false; bool bSetOrigClip = false; bool bSkip = false; if((pPrevRect == NULL) && pG->queryProperties(GR_Graphics::DGP_SCREEN)) { pDA->pG->setClipRect(pRect); UT_DEBUGMSG(("Clip bottom is %d \n",pRect->top + pRect->height)); bRemoveRectAfter = true; } else if(pPrevRect && !pRect->intersectsRect(pPrevRect)) { bSkip = true; xxx_UT_DEBUGMSG(("External Clip bottom is %d \n",pRect->top + pRect->height)); } else if(pPrevRect) { newRect.top = UT_MAX(pPrevRect->top,pRect->top); UT_sint32 iBotPrev = pPrevRect->height + pPrevRect->top; UT_sint32 iBot = pRect->height + pRect->top; newRect.height = UT_MIN(iBotPrev,iBot) - newRect.top; newRect.width = pPrevRect->width; newRect.left = pPrevRect->left; if((newRect.height > 0) && pDA->pG->queryProperties(GR_Graphics::DGP_SCREEN)) { pDA->pG->setClipRect(&newRect); bSetOrigClip = true; } else { bSkip = true; } } if(!bSkip) { for (UT_uint32 i = 0; i<count; i++) { fp_ContainerObject* pContainer = static_cast<fp_ContainerObject*>(getNthCon(i)); da.xoff = pDA->xoff + pContainer->getX(); da.yoff = pDA->yoff + pContainer->getY(); pContainer->draw(&da); } } m_bNeverDrawn = false; m_bOverWrote = false; if(bRemoveRectAfter) { pDA->pG->setClipRect(NULL); } if(bSetOrigClip) { pDA->pG->setClipRect(pPrevRect); } delete pRect; drawBoundaries(pDA); }
void AP_Dialog_FormatTable::setCurCellProps(void) { XAP_Frame *frame = XAP_App::getApp()->getLastFocussedFrame(); if (frame) { FV_View * pView = static_cast<FV_View *>(frame->getCurrentView()); if (m_bSettingsChanged || m_iOldPos == pView->getPoint()) // comparing the actual cell pos would be even better; but who cares :) return; m_iOldPos = pView->getPoint(); /* * update the border colors */ gchar * color = NULL; if (pView->getCellProperty("left-color", color)) m_vecProps.addOrReplaceProp("left-color", color); else m_vecProps.removeProp("left-color"); if (pView->getCellProperty("right-color", color)) m_vecProps.addOrReplaceProp("right-color", color); else m_vecProps.removeProp("right-color"); if (pView->getCellProperty("top-color", color)) m_vecProps.addOrReplaceProp("top-color", color); else m_vecProps.removeProp("top-color"); if (pView->getCellProperty("bot-color", color)) m_vecProps.addOrReplaceProp("bot-color", color); else m_vecProps.removeProp("bot-color"); /* * update the background color */ UT_RGBColor clr; gchar * bgColor = NULL; if (pView->getCellProperty("background-color", bgColor)) { m_vecProps.addOrReplaceProp("background-color", bgColor); clr.setColor(bgColor); setBackgroundColorInGUI(clr); } else { m_vecProps.removeProp("background-color"); setBackgroundColorInGUI(UT_RGBColor(255,255,255)); // No color == white for now - MARCM } if(pView->isImageAtStrux(m_iOldPos,PTX_SectionCell)) { if(pView->isInTable()) { fl_BlockLayout * pBL = pView->getCurrentBlock(); fl_CellLayout * pCell = static_cast<fl_CellLayout *>(pBL->myContainingLayout()); if(pCell->getContainerType() != FL_CONTAINER_CELL) { UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN); DELETEP(m_pGraphic); DELETEP(m_pImage); m_sImagePath.clear(); } else { FG_Graphic * pFG = FG_GraphicRaster::createFromStrux(pCell); if(pFG) { DELETEP(m_pGraphic); DELETEP(m_pImage); m_sImagePath.clear(); m_pGraphic = pFG; m_sImagePath = pFG->getDataId(); GR_Graphics * pG = m_pFormatTablePreview->getGraphics(); const UT_ByteBuf * pBB = pFG->getBuffer(); if(m_pGraphic->getType() == FGT_Raster) { m_pImage = static_cast<GR_Image *>( pG->createNewImage( m_sImagePath.c_str(), pBB, pFG->getMimeType(), pFG->getWidth(), pFG->getHeight(), GR_Image::GRT_Raster)); } else { m_pImage = static_cast<GR_Image *>( pG->createNewImage( m_sImagePath.c_str(), pBB, pFG->getMimeType(), m_pFormatTablePreview->getWindowWidth()-2, m_pFormatTablePreview->getWindowHeight()-2, GR_Image::GRT_Vector)); } } } } else { DELETEP(m_pGraphic); DELETEP(m_pImage); m_sImagePath.clear(); } } else { DELETEP(m_pGraphic); DELETEP(m_pImage); m_sImagePath.clear(); } UT_String bstmp = UT_String_sprintf("%d", FS_FILL); m_vecProps.addOrReplaceProp("bg-style", bstmp.c_str()); // draw the preview with the changed properties if(m_pFormatTablePreview) m_pFormatTablePreview->queueDraw(); } }
void fp_EmbedRun::_draw(dg_DrawArgs* pDA) { GR_Graphics *pG = pDA->pG; #if 0 UT_DEBUGMSG(("Draw with class %x \n",pG)); UT_DEBUGMSG(("Contents of fp EmbedRun \n %s \n",m_sEmbedML.utf8_str())); #endif FV_View* pView = _getView(); UT_return_if_fail(pView); // need to draw to the full height of line to join with line above. UT_sint32 xoff= 0, yoff=0, DA_xoff = pDA->xoff; getLine()->getScreenOffsets(this, xoff, yoff); // need to clear full height of line, in case we had a selection UT_sint32 iFillHeight = getLine()->getHeight(); UT_sint32 iFillTop = pDA->yoff - getLine()->getAscent(); UT_uint32 iSelAnchor = pView->getSelectionAnchor(); UT_uint32 iPoint = pView->getPoint(); UT_uint32 iSel1 = UT_MIN(iSelAnchor, iPoint); UT_uint32 iSel2 = UT_MAX(iSelAnchor, iPoint); UT_ASSERT(iSel1 <= iSel2); UT_uint32 iRunBase = getBlock()->getPosition() + getOffsetFirstVis(); // Fill with background, then redraw. UT_sint32 iLineHeight = getLine()->getHeight(); bool bIsSelected = false; if ( !pG->queryProperties(GR_Graphics::DGP_PAPER) && (isInSelectedTOC() || (iSel1 <= iRunBase && iSel2 > iRunBase)) ) { // Need the painter lock to be released at the end of this block GR_Painter painter(pG); painter.fillRect(_getView()->getColorSelBackground(), /*pDA->xoff*/DA_xoff, iFillTop, getWidth(), iFillHeight); bIsSelected = true; getEmbedManager()->setColor(m_iEmbedUID,_getView()->getColorSelForeground()); } else { Fill(getGraphics(),pDA->xoff, pDA->yoff - getAscent(), getWidth()+getGraphics()->tlu(1), iLineHeight+getGraphics()->tlu(1)); getEmbedManager()->setColor(m_iEmbedUID,getFGColor()); } UT_Rect rec; rec.left = pDA->xoff; rec.top = pDA->yoff; rec.height = getHeight(); rec.width = getWidth(); if(getEmbedManager()->isDefault()) { rec.top -= _getLayoutPropFromObject("ascent"); } UT_DEBUGMSG(("Draw Embed object top %d \n",rec.top)); getEmbedManager()->render(m_iEmbedUID,rec); if(m_bNeedsSnapshot && !getEmbedManager()->isDefault() && getGraphics()->queryProperties(GR_Graphics::DGP_SCREEN) ) { UT_Rect myrec = rec; myrec.top -= getAscent(); if(!bIsSelected) { getEmbedManager()->makeSnapShot(m_iEmbedUID,myrec); m_bNeedsSnapshot = false; } } if(bIsSelected) { UT_Rect myrec = rec; if(!getEmbedManager()->isDefault()) { myrec.top -= getAscent(); } _drawResizeBox(myrec); } }
/*! * This loads all the properties of the container found in the piecetable * into the physical frame container */ void fl_FrameLayout::setContainerProperties(void) { fp_FrameContainer * pFrame = static_cast<fp_FrameContainer *>(getLastContainer()); if(pFrame == NULL) { UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN); return; } pFrame->setBackground(m_background ); pFrame->setBottomStyle(m_lineBottom ); pFrame->setTopStyle(m_lineTop ); pFrame->setLeftStyle(m_lineLeft ); pFrame->setRightStyle(m_lineRight ); pFrame->setXpad(m_iXpad); pFrame->setYpad(m_iYpad); pFrame->setTightWrapping(m_bIsTightWrap); if(FL_FRAME_BELOW_TEXT == m_iFrameWrapMode) { pFrame->setAbove(false); } else if(FL_FRAME_WRAPPED_TO_RIGHT == m_iFrameWrapMode) { pFrame->setRightWrapped(true); } else if(FL_FRAME_WRAPPED_TO_LEFT == m_iFrameWrapMode) { pFrame->setLeftWrapped(true); } else if(FL_FRAME_WRAPPED_TOPBOT == m_iFrameWrapMode) { pFrame->setTopBot(true); } // // Now do the image for this frame. // if(m_pGraphicImage) { if(m_pImageImage == NULL) { const PP_AttrProp * pAP = NULL; getAP(pAP); GR_Graphics * pG = getDocLayout()->getGraphics(); UT_sint32 iWidth = pG->tlu(100); UT_sint32 iHeight = pG->tlu(100); if(m_pGraphicImage->getType() == FGT_Raster) { iWidth = pG->tlu(m_pGraphicImage->getWidth()); iHeight = pG->tlu(m_pGraphicImage->getHeight()); } GR_Image * pImage = m_pGraphicImage->generateImage(pG,pAP,iWidth,iHeight); m_iDocImageWidth = pFrame->getFullWidth(); m_iDocImageHeight = pFrame->getFullHeight(); m_iGraphicTick = getDocLayout()->getGraphicTick(); UT_Rect rec(0,0,pFrame->getFullWidth(),pFrame->getFullHeight()); if(rec.width < pG->tlu(3)) { rec.width = pG->tlu(3); } if(rec.height < pG->tlu(3)) { rec.height = pG->tlu(3); } if(pImage) { pImage->scaleImageTo(pG,rec); } m_pImageImage = pImage; } pFrame->getFillType()->setImagePointer(&m_pGraphicImage,&m_pImageImage); } if(m_iFrameWrapMode >= FL_FRAME_WRAPPED_TO_RIGHT) { // // Set text wrapping around frame // pFrame->setWrapping(true); } pFrame->setPreferedPageNo(m_iPrefPage); }
void fl_FrameLayout::_lookupMarginProperties(const PP_AttrProp* pSectionAP) { UT_return_if_fail(pSectionAP); FV_View * pView = getDocLayout()->getView(); GR_Graphics * pG = getDocLayout()->getGraphics(); UT_return_if_fail( pView && pG ); UT_sint32 iFramePositionTo = m_iFramePositionTo; FL_FrameWrapMode iFrameWrapMode = m_iFrameWrapMode; bool bIsTightWrap = m_bIsTightWrap; UT_sint32 iXpos = m_iXpos; UT_sint32 iYpos = m_iYpos; UT_sint32 iXColumn = m_iXColumn; UT_sint32 iYColumn = m_iYColumn; UT_sint32 iXPage = m_iXPage; UT_sint32 iYPage = m_iYPage; if(pView->getViewMode() == VIEW_NORMAL && !pG->queryProperties(GR_Graphics::DGP_PAPER)) { m_iFramePositionTo = FL_FRAME_POSITIONED_TO_BLOCK; m_iFrameWrapMode = FL_FRAME_WRAPPED_TO_RIGHT; m_bIsTightWrap = false; m_iXpos = 0; m_iYpos = 0; m_iXColumn = 0; m_iYColumn = 0; m_iXPage = 0; m_iYPage = 0; } else { const gchar *pszPositionTo = NULL; const gchar *pszWrapMode = NULL; const gchar *pszXpos = NULL; const gchar *pszYpos = NULL; const gchar *pszColXpos = NULL; const gchar *pszColYpos = NULL; const gchar *pszPageXpos = NULL; const gchar *pszPageYpos = NULL; const gchar * pszTightWrapped = NULL; // Position-to if(!pSectionAP || !pSectionAP->getProperty("position-to",pszPositionTo)) { m_iFramePositionTo = FL_FRAME_POSITIONED_TO_BLOCK; } else if(strcmp(pszPositionTo,"block-above-text") == 0) { m_iFramePositionTo = FL_FRAME_POSITIONED_TO_BLOCK; } else if(strcmp(pszPositionTo,"column-above-text") == 0) { m_iFramePositionTo = FL_FRAME_POSITIONED_TO_COLUMN; } else if(strcmp(pszPositionTo,"page-above-text") == 0) { m_iFramePositionTo = FL_FRAME_POSITIONED_TO_PAGE; } else { UT_DEBUGMSG(("Unknown Position to %s \n",pszPositionTo)); UT_ASSERT(UT_SHOULD_NOT_HAPPEN); m_iFramePositionTo = FL_FRAME_POSITIONED_TO_BLOCK; } // wrap-mode if(!pSectionAP || !pSectionAP->getProperty("wrap-mode",pszWrapMode)) { m_iFrameWrapMode = FL_FRAME_ABOVE_TEXT; } else if(strcmp(pszWrapMode,"above-text") == 0) { m_iFrameWrapMode = FL_FRAME_ABOVE_TEXT; } else if(strcmp(pszWrapMode,"below-text") == 0) { m_iFrameWrapMode = FL_FRAME_BELOW_TEXT; } else if(strcmp(pszWrapMode,"wrapped-to-right") == 0) { m_iFrameWrapMode = FL_FRAME_WRAPPED_TO_RIGHT; } else if(strcmp(pszWrapMode,"wrapped-to-left") == 0) { m_iFrameWrapMode = FL_FRAME_WRAPPED_TO_LEFT; } else if(strcmp(pszWrapMode,"wrapped-both") == 0) { m_iFrameWrapMode = FL_FRAME_WRAPPED_BOTH_SIDES; } else if(strcmp(pszWrapMode,"wrapped-topbot") == 0) { m_iFrameWrapMode = FL_FRAME_WRAPPED_TOPBOT; } else { UT_DEBUGMSG(("Unknown wrap-mode %s \n",pszWrapMode)); UT_ASSERT(UT_SHOULD_NOT_HAPPEN); m_iFrameWrapMode = FL_FRAME_ABOVE_TEXT; } // // Wrap type // if(!pSectionAP || !pSectionAP->getProperty("tight-wrap",pszTightWrapped)) { m_bIsTightWrap = false; } else if(strcmp(pszTightWrapped,"1") == 0) { m_bIsTightWrap = true; } else { m_bIsTightWrap = false; } // Xpos if(!pSectionAP || !pSectionAP->getProperty("xpos",pszXpos)) { m_iXpos = 0; } else { m_iXpos = UT_convertToLogicalUnits(pszXpos); } UT_DEBUGMSG(("xpos for frame is %s \n",pszXpos)); // Ypos if(!pSectionAP || !pSectionAP->getProperty("ypos",pszYpos)) { m_iYpos = 0; } else { m_iYpos = UT_convertToLogicalUnits(pszYpos); } UT_DEBUGMSG(("ypos for frame is %s \n",pszYpos)); // ColXpos if(!pSectionAP || !pSectionAP->getProperty("frame-col-xpos",pszColXpos)) { m_iXColumn = 0; } else { m_iXColumn = UT_convertToLogicalUnits(pszColXpos); } UT_DEBUGMSG(("ColXpos for frame is %s \n",pszColXpos)); // colYpos if(!pSectionAP || !pSectionAP->getProperty("frame-col-ypos",pszColYpos)) { m_iYColumn = 0; } else { m_iYColumn = UT_convertToLogicalUnits(pszColYpos); } UT_DEBUGMSG(("ColYpos for frame is %s units %d \n",pszColYpos,m_iYColumn)); // PageXpos if(!pSectionAP || !pSectionAP->getProperty("frame-page-xpos",pszPageXpos)) { m_iXPage = 0; } else { m_iXPage = UT_convertToLogicalUnits(pszPageXpos); } UT_DEBUGMSG(("PageXpos for frame is %s \n",pszPageXpos)); // PageYpos if(!pSectionAP || !pSectionAP->getProperty("frame-page-ypos",pszPageYpos)) { m_iYPage = 0; } else { m_iYPage = UT_convertToLogicalUnits(pszPageYpos); } UT_DEBUGMSG(("PageYpos for frame is %s units %d \n",pszColYpos,m_iYPage)); } fl_ContainerLayout* pCL = getFirstLayout(); while (pCL) { pCL->lookupMarginProperties(); pCL = pCL->getNext(); } if(iFramePositionTo != m_iFramePositionTo || iFrameWrapMode != m_iFrameWrapMode || bIsTightWrap != m_bIsTightWrap || iXpos != m_iXpos || iYpos != m_iYpos || iXColumn != m_iXColumn || iYColumn != m_iYColumn || iXPage != m_iXPage || iYPage != m_iYPage) { collapse(); } }