/*!
 * 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 XAP_CustomWidgetLU::queueDrawLU(const UT_Rect *clip)
{
	GR_Graphics *gr = getGraphics();
	UT_ASSERT(gr);

	if (clip == NULL)
		queueDraw();
	else
	{
		UT_Rect r(
				gr->tdu(clip->left),
				gr->tdu(clip->top),
				gr->tdu(clip->width),
				gr->tdu(clip->height)
			);
		queueDraw(&r);
	}
}
Beispiel #3
0
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)));
    }
}