/*!
 * 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));
}
Пример #2
0
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);
	}
}
Пример #3
0
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;
}
Пример #4
0
/*!
 * 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);
}