Ejemplo n.º 1
0
void HTMLTableCell::print( QPainter *_painter, HTMLChain *_chain, int _x,
	int _y, int _width, int _height, int _tx, int _ty )
{
    if ( bg.isValid() )
    {
	    int top = _y - ( y - getAscent() );
	    int bottom = top + _height;
	    if ( top < -padding )
		    top = -padding;
	    if ( bottom > getAscent() + padding )
		    bottom = getAscent() + padding;

	    int left = _x - x;
	    int right = left + _width;
	    if ( left < -padding )
		left = -padding;
	    if ( right > width + padding )
		right = width + padding;

	    QBrush brush( bg );
	    _painter->fillRect( _tx + x + left, _ty + y - ascent + top,
		    right - left, bottom - top, brush );

	    // another hack...
	    HTMLObject *obj;
	    for ( obj = head; obj != 0; obj = obj->next() )
		obj->setBgColor(bg);
    }

    HTMLClue::print( _painter, _chain, _x, _y, _width, _height, _tx, _ty );
}
Ejemplo n.º 2
0
bool HTMLTableCell::print( QPainter *_painter, int _x, int _y, int _width,
	int _height, int _tx, int _ty, bool toPrinter )
{
	if ( _y + _height < y - getAscent() || _y > y + descent )
		return false;

 	if ( bg.isValid() )
	{
		int top = _y - ( y - getAscent() );
		int bottom = top + _height;
		if ( top < -padding )
			top = -padding;
		if ( bottom > getAscent() + padding )
			bottom = getAscent() + padding;

 		QBrush brush( bg );
		_painter->fillRect( _tx + x - padding, _ty + y - ascent + top,
			width + padding * 2, bottom - top, brush );

	    // another hack... 
	    HTMLObject *obj;
	    for ( obj = head; obj != 0; obj = obj->next() )
		obj->setBgColor(bg);
	}

	return HTMLClueV::print( _painter, _x, _y, _width, _height, _tx, _ty, toPrinter );
}
Ejemplo n.º 3
0
bool HTMLClueV::print( QPainter *_painter, int _x, int _y, int _width, int _height, int _tx, int _ty, bool toPrinter )
{
    bool rv = HTMLClue::print( _painter, _x, _y, _width, _height, _tx, _ty, toPrinter );

    // print aligned objects
    if ( _y + _height < y - getAscent() || _y > y + descent )
	return rv;
    
    _tx += x;
    _ty += y - ascent;

    HTMLClueAligned *clue;

    for ( clue = alignLeftList; clue != 0; clue = clue->nextClue() )
    {
	clue->print( _painter, _tx + clue->parent()->getXPos(),
		_ty + clue->parent()->getYPos() - clue->parent()->getAscent() );
    }

    for ( clue = alignRightList; clue != 0; clue = clue->nextClue() )
    {
	clue->print( _painter, _tx + clue->parent()->getXPos(),
		_ty + clue->parent()->getYPos() - clue->parent()->getAscent() );
    }
    
    return rv;
}
Ejemplo n.º 4
0
bool HTMLClue::print( QPainter *_painter, int _x, int _y, int _width, int _height, int _tx, int _ty, bool toPrinter )
{
    if ( _y + _height < y - getAscent() || _y > y + descent )
	return false;
    
    HTMLObject *obj;

    _tx += x;
    _ty += y - ascent;

#ifdef CLUE_DEBUG
    // draw rectangles around clues - for debugging
    QBrush brush;
    _painter->setBrush( brush );
    _painter->drawRect( _tx, _ty, width, getHeight() );
#endif

    for ( obj = head; obj != 0; obj = obj->next() )
    {
	if ( !obj->isAligned() )
	{
	    if ( obj->print( _painter, _x - x, _y - (y - ascent),
			_width, _height, _tx, _ty, toPrinter ) && toPrinter )
	    return true;
	}
    }

    return false;
}
Ejemplo n.º 5
0
void HTMLTable::print( QPainter *_painter, HTMLObject *_obj, int _x, int _y, int _width, int _height, int _tx, int _ty )
{
    if ( _y + _height < y - getAscent() || _y > y + descent )
	return;

    _tx += x;
    _ty += y - ascent;

    unsigned int r, c;
    HTMLTableCell *cell;

    for ( r = 0; r < totalRows; r++ )
    {
	for ( c = 0; c < totalCols; c++ )
	{
	    if ( ( cell = cells[r][c] ) == 0 )
		continue;
	    if ( c < totalCols - 1 && cell == cells[r][c+1] )
		continue;
	    if ( r < totalRows - 1 && cells[r+1][c] == cell )
		continue;
	    cell->print( _painter, _obj, _x - x, _y - (y - ascent),
		_width, _height, _tx, _ty );
	}
    }
}
Ejemplo n.º 6
0
double GLText::getAscent(const char* str)
{
  double ascent = 0.0;
  while(*str>0){
    ascent = max(ascent,getAscent(*str));
    str++;
  }
  return ascent;
}
Ejemplo n.º 7
0
void GLText::drawString(vector2d loc, double angle, double size, const char* str, HAlignOptions hAlign, VAlignOptions vAlign)
{
  glMatrixMode(GL_MODELVIEW);
  glPushMatrix();
  glLoadIdentity();
  glTranslated(loc.x,loc.y,0.0);
  glScaled(size, size,1.0);
  glRotated(angle,0,0,1);
  
  switch(hAlign){
    case LeftAligned:{
      //Normal rendering will achieve this!
      break;
    }
    case RightAligned:{
      glTranslated(-getWidth(str),0,0);
      break;
    }
    case CenterAligned:{
      glTranslated(-0.5*getWidth(str),0,0);
      break;
    }
  }
  switch(vAlign){
    case BottomAligned:{
      glTranslated(0.0,getDescent(str),0.0);
      break;
    }
    case TopAligned:{
      glTranslated(0.0,-getAscent(str),0.0);
      break;
    }
    case MedianAligned:{
      //Normal rendering will achieve this!
      break;
    }
    case MiddleAligned:{
      glTranslated(0.0,-0.5*getHeight(str),0.0);
      break;
    }
  }
  vector2d textDir;
  textDir.heading(0);
  double d = 0.0;
  while(*str>0){
    drawGlyph(*str);
    d = characterSpacing + 0.5*getWidth(*str);
    str++;
    if((*str)>0){
      d += 0.5*getWidth(*str);
      glTranslated(d*textDir.x,d*textDir.y,0.0);
    }
  }
  glPopMatrix();
}
Ejemplo n.º 8
0
 float VirtualFont::getOffsetY(const LineLayout &layout, Alignment align) const
 {
     switch (align)
     {
         case ALIGN_MIDDLE:
             return (middleLineFactor != 0) ? (middleLineFactor * (layout.maxAscent - layout.maxDescent) * sizeRatio) : getStrikethroughOffset(layout);
             
         case ALIGN_TOP:
             return +getAscent(layout);
             
         case ALIGN_BOTTOM:
             return -getDescent(layout);
             
         default:
             return 0;
     }
 }
Ejemplo n.º 9
0
void HTMLClue::print( QPainter *_painter, HTMLObject *_obj, int _x, int _y, int _width, int _height, int _tx, int _ty )
{
    if ( _y + _height < y - getAscent() || _y > y + descent )
	return;
    
    HTMLObject *obj;

    _tx += x;
    _ty += y - ascent;

    for ( obj = head; obj != 0; obj = obj->next() )
    {
	if ( obj == _obj )
	{
	    obj->print( _painter, _x - x, _y - (y - ascent), _width,	
		_height, _tx, _ty, false );
	    return;
	}
	else
	    obj->print( _painter, _obj, _x - x, _y - (y - ascent),
		_width, _height, _tx, _ty );
    }
}
Ejemplo n.º 10
0
bool HTMLCell::print( QPainter *_painter, int _x, int _y, int _width, int _height, int _tx, int _ty, bool toPrinter )
{
  bool rv = HTMLClueV::print( _painter, _x, _y, _width, _height, _tx, _ty, toPrinter );
  
  // print aligned objects
  if ( _y + _height < y - getAscent() || _y > y + descent )
    return rv;
  
  if ( !toPrinter && bIsMarked )
  {
    QPen pen( _painter->pen() );
    QPen newPen( black );
    _painter->setPen( newPen );
    _painter->drawRect( _tx + x, _ty + y - ascent, width, ascent + descent );
    newPen.setColor( white );
    newPen.setStyle( DotLine );
    _painter->setPen( newPen );
    _painter->drawRect( _tx + x, _ty + y - ascent, width, ascent + descent );
    _painter->setPen( pen );
  }
    
  return rv;
}
Ejemplo n.º 11
0
void fp_EmbedRun::findPointCoords(UT_uint32 iOffset, UT_sint32& x, UT_sint32& y, UT_sint32& x2, UT_sint32& y2, UT_sint32& height, bool& bDirection)
{
	//UT_DEBUGMSG(("fintPointCoords: ImmageRun\n"));
	UT_sint32 xoff;
	UT_sint32 yoff;

	UT_ASSERT(getLine());

	getLine()->getOffsets(this, xoff, yoff);
	if (iOffset == (getBlockOffset() + getLength()))
	{
		x = xoff + getWidth();
		x2 = x;
	}
	else
	{
		x = xoff;
		x2 = x;
	}
	y = yoff + getAscent() - m_iPointHeight;
	height = m_iPointHeight;
	y2 = y;
	bDirection = (getVisDirection() != UT_BIDI_LTR);
}
Ejemplo n.º 12
0
void CFormulaNode::Recalculate_VerticalCenter( const SizeFde &sz )
{
	RealFde vc = sz.height() / 2.0;

	switch( getAlignmentType() )
	{
	case FBtnChildPos::Child:
		if( getAlignmentValue() >= 1 && (getAlignmentValue() - 1) < getGraphPrimNumber() )
		{
			const RectFde& _t = getGraphPrimitivePositionRect( getAlignmentValue() - 1 );
			vc = (_t.top() + _t.bottom()) / 2.0;
		}
		break;
	case FBtnChildPos::Child_Average:
		if( getAlignmentValue() >= 1 && (getAlignmentValue() - 1) < getGraphPrimNumber() )
		{
			vc = 0.0;
			for( long i = 0; i <= getAlignmentValue() - 1; i++ )
			{
				const RectFde& _t = getGraphPrimitivePositionRect( i );
				vc += _t.top() + _t.bottom();
			}
			vc = vc / (getAlignmentValue() * 2.0);
		}
		break;
	case FBtnChildPos::MSPACE_Exact_HeightDepth:
	case FBtnChildPos::Frame:
		if( (getAlignmentValue() - 1) >= 0 && (getAlignmentValue() - 1) < GetChildCount() )
		{
			CNode *pNode = GetChild( getAlignmentValue() - 1 );
			if( pNode )
				vc = pNode->GetPosition().y() + pNode->GetVerticalCenter();
		}
		break;
	case FBtnChildPos::Frame_Blank_Average:
		{
			CNode *pNodeFirst = GetFirstChild();
			CNode *pNodeLast  = GetLastChild();
			if( pNodeFirst != NULL && pNodeLast != NULL )
			{
				vc = (pNodeFirst->GetPosition().y() + pNodeFirst->GetSize().height() + pNodeLast->GetPosition().y()) / 2.0;
			}
		}
		break;
	case FBtnChildPos::Half:
		break;

	case FBtnChildPos::TableAxis:
		if( (getAlignmentValue() - 1) >= 0 && (getAlignmentValue() - 1) < GetChildCount() )
		{
			CNode *pNode = GetChild( getAlignmentValue() - 1 );
			if( pNode )
				vc = pNode->GetPosition().y() + pNode->GetSize().height() / 2.0;
		}
		break;

	case FBtnChildPos::TableCenter2Baseline:
	case FBtnChildPos::TableTop2Baseline:
	case FBtnChildPos::TableBottom2Baseline:
		{
			RealFde asc = ::getCurrentDefaultAscent( GetLevel() );
			RealFde h = ::getCurrentDefaultSize( GetLevel() ).height();
			vc = getAscent( sz ) - asc + h - asc / 2.0;
		}
		break;

	default:
		break;
	}

	SetVerticalCenter( vc );
}
Ejemplo n.º 13
0
float Font::getDescent() const
{
    return font->height - getAscent();
}
Ejemplo n.º 14
0
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);

}
Ejemplo n.º 15
0
le_int32 LEFontInstance::getLineHeight() const
{
    return getAscent() + getDescent() + getLeading();
}
Ejemplo n.º 16
0
bool HTMLTable::print( QPainter *_painter, int _x, int _y, int _width, int _height, int _tx, int _ty, bool toPrinter )
{
    if ( _y + _height < y - getAscent() || _y > y + descent )
	return false;

    _tx += x;
    _ty += y - ascent;

    unsigned int r, c;
    int cindx, rindx;
    HTMLTableCell *cell;
    QArray<bool> colsDone( totalCols );
    colsDone.fill( false );

    if ( caption )
    {
	caption->print( _painter, _x - x, _y - (y - ascent),
	    _width, _height, _tx, _ty, toPrinter );
    }

    // draw the cells
    for ( r = 0; r < totalRows; r++ )
    {
	for ( c = 0; c < totalCols; c++ )
	{
	    if ( ( cell = cells[r][c] ) == 0 )
		continue;
	    if ( c < totalCols - 1 && cell == cells[r][c+1] )
		continue;
	    if ( r < totalRows - 1 && cells[r+1][c] == cell )
		continue;
	    if ( colsDone[c] )
		continue;
	    if ( cell->print( _painter, _x - x, _y - (y - ascent),
		    _width, _height, _tx, _ty, toPrinter ) )
		colsDone[c] = true;
	}
    }

    // draw the border - needs work to print to printer
    if ( border && !toPrinter )
    {
	int capOffset = 0;
	if ( caption && capAlign == HTMLClue::Top )
	    capOffset = caption->getHeight();
	QColorGroup colorGrp( black, lightGray, white, darkGray, gray,
	    black, white );
	qDrawShadePanel( _painter, _tx, _ty + capOffset, width,
	    rowHeights[totalRows] + border, colorGrp, false, border );

	// draw borders around each cell
	for ( r = 0; r < totalRows; r++ )
	{
	    for ( c = 0; c < totalCols; c++ )
	    {
		if ( ( cell = cells[r][c] ) == 0 )
		    continue;
		if ( c < totalCols - 1 && cell == cells[r][c+1] )
		    continue;
		if ( r < totalRows - 1 && cells[r+1][c] == cell )
		    continue;

		if ( ( cindx = c-cell->colSpan()+1 ) < 0 )
		    cindx = 0;
		if ( ( rindx = r-cell->rowSpan()+1 ) < 0 )
		    rindx = 0;

		qDrawShadePanel(_painter,
		    _tx + columnOpt[cindx],
		    _ty + rowHeights[rindx] + capOffset,
		    columnOpt[c+1] - columnOpt[cindx] - spacing,
		    rowHeights[r+1] - rowHeights[rindx] - spacing,
		    colorGrp, TRUE, 1 );
	    }
	}
    }

    for ( c = 0; c < totalCols; c++ )
    {
	if ( colsDone[c] == true )
	    return true;
    }

    return false;
}
Ejemplo n.º 17
0
float Font::getAscentInPoints() const       { return getAscent()  * getHeightToPointsFactor(); }
Ejemplo n.º 18
0
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);
	}
}
Ejemplo n.º 19
0
/*!
 * Returns true if the properties are changed in the document.
 */
bool fp_EmbedRun::_updatePropValuesIfNeeded(void)
{
  UT_sint32 iVal = 0;
  if(getEmbedManager()->isDefault())
    {
      return false;
    }
  PT_AttrPropIndex api = getBlock()->getDocument()->getAPIFromSOH(m_OH);
  const PP_AttrProp * pAP = NULL;
  const char * szPropVal = NULL;
  getBlock()->getDocument()->getAttrProp(api, &pAP);
  UT_return_val_if_fail(pAP,false);
  bool bFound = pAP->getProperty("height", szPropVal);
  bool bDoUpdate = false;
  if(bFound)
    {
      iVal = UT_convertToLogicalUnits(szPropVal);
      bDoUpdate = (iVal != getHeight());
    }
  else
    {
      bDoUpdate = true;
    }
  bFound = pAP->getProperty("width", szPropVal);
  if(bFound && !bDoUpdate)
    {
      iVal = UT_convertToLogicalUnits(szPropVal);
      bDoUpdate = (iVal != getWidth());
    }
  else
    {
      bDoUpdate = true;
    }
  bFound = pAP->getProperty("ascent", szPropVal);
  if(bFound && !bDoUpdate)
    {
      iVal = UT_convertToLogicalUnits(szPropVal);
      bDoUpdate = (iVal != static_cast<UT_sint32>(getAscent()));
    }
  else
    {
      bDoUpdate = true;
    }
  bFound = pAP->getProperty("descent", szPropVal);
  if(bFound && !bDoUpdate)
    {
      iVal = UT_convertToLogicalUnits(szPropVal);
      bDoUpdate = (iVal != static_cast<UT_sint32>(getDescent()));
    }
  else
    {
      bDoUpdate = true;
    }
  if(bDoUpdate)
    {
      const char * pProps[10] = {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};
	  UT_LocaleTransactor t(LC_NUMERIC, "C");
	  UT_UTF8String sHeight,sWidth,sAscent,sDescent;
      UT_UTF8String_sprintf(sHeight,"%fin",static_cast<double>(getHeight())/1440.);
      pProps[0] = "height";
      pProps[1] = sHeight.utf8_str();
      UT_UTF8String_sprintf(sWidth,"%fin",static_cast<double>(getWidth())/1440.);
      pProps[2] = "width";
      pProps[3] = sWidth.utf8_str();
      UT_UTF8String_sprintf(sAscent,"%fin",static_cast<double>(getAscent())/1440.);
      pProps[4] = "ascent";
      pProps[5] = sAscent.utf8_str();
      UT_UTF8String_sprintf(sDescent,"%fin",static_cast<double>(getDescent())/1440.);
      pProps[6] = "descent";
      pProps[7] = sDescent.utf8_str();
      getBlock()->getDocument()->changeObjectFormatNoUpdate(PTC_AddFmt,m_OH,
							    NULL,
							    pProps);
      return true;
    }
  return false;
}