Пример #1
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)));
    }
}
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);
	}
}
Пример #3
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)));
}