Exemplo n.º 1
0
/* virtual */ void
nsMathMLmfencedFrame::GetIntrinsicWidthMetrics(nsRenderingContext* aRenderingContext, nsHTMLReflowMetrics& aDesiredSize)
{
  nscoord width = 0;

  nsPresContext* presContext = PresContext();
  const nsStyleFont* font = StyleFont();
  nsRefPtr<nsFontMetrics> fm;
  nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm));
  nscoord em;
  GetEmHeight(fm, em);

  if (mOpenChar) {
    width +=
      GetMaxCharWidth(presContext, aRenderingContext, mOpenChar,
                      NS_MATHML_OPERATOR_FORM_PREFIX, font->mScriptLevel, em);
  }

  int32_t i = 0;
  nsIFrame* childFrame = GetFirstPrincipalChild();
  while (childFrame) {
    // XXX This includes margin while Reflow currently doesn't consider
    // margin, so we may end up with too much space, but, with stretchy
    // characters, this is an approximation anyway.
    width += nsLayoutUtils::IntrinsicForContainer(aRenderingContext, childFrame,
                                                  nsLayoutUtils::PREF_WIDTH);

    if (i < mSeparatorsCount) {
      width +=
        GetMaxCharWidth(presContext, aRenderingContext, &mSeparatorsChar[i],
                        NS_MATHML_OPERATOR_FORM_INFIX, font->mScriptLevel, em);
    }
    i++;

    childFrame = childFrame->GetNextSibling();
  }

  if (mCloseChar) {
    width +=
      GetMaxCharWidth(presContext, aRenderingContext, mCloseChar,
                      NS_MATHML_OPERATOR_FORM_POSTFIX, font->mScriptLevel, em);
  }

  aDesiredSize.Width() = width;
  aDesiredSize.mBoundingMetrics.width = width;
  aDesiredSize.mBoundingMetrics.leftBearing = 0;
  aDesiredSize.mBoundingMetrics.rightBearing = width;
}
Exemplo n.º 2
0
//__________________________________________________________________
void	_HYSequencePane::SetFont(_HYFont newFont)
{
	charWidth = GetMaxCharWidth (newFont)+1;
	StartDraw ();
	_HYGraphicPane::SetFont (newFont);
	EndDraw ();
	SetHeaders (nil,false);
}
Exemplo n.º 3
0
_HYSequencePane::_HYSequencePane(_HYRect s, Ptr p, int h, int w):_HYCanvas (s,p,h,w,32)
{
	startColumn = endColumn = startRow = endRow = headerWidth = 0;
	for (long i=0; i<256; i++)
		colorMap[i] = 0;
	_HYFont displayFont;
	#ifdef __MAC__
		displayFont.face = "Monaco";
		displayFont.size = 10;
	#endif
	#ifdef __WINDOZE__
		displayFont.face = "Courier";
		displayFont.size = 14;	
	#endif
	#ifdef __HYPHY_GTK__
		displayFont.face = _HY_MONO_FONT;
		displayFont.size = 12;	
	#endif
	displayFont.style = HY_FONT_PLAIN;
	StartDraw();
	_HYGraphicPane::SetFont(displayFont);
	EndDraw();
	charWidth    = GetMaxCharWidth (displayFont)+1;
	invertColors = false;
	backColor = (_HYColor)
	{
		0xDE,0xDE,0xDE
	};

	headerColor = (_HYColor)
	{
		180,167,150
	};
	
	highlightColor = (_HYColor)
	{
		75,75,75
	};

	characterColors<<0;
	headerWidth = 0;
	blockWidth = 10;
	recentClick = -1;
	showDots = false;
	nameDisplayFlags = HY_SEQUENCE_PANE_NAMES_ALL;
	shortHeaderWidth = 0;
	fullHeaderWidth = 0;
	active = true;
	numbers = true;
	dragScrollCounter = 0;
}
Exemplo n.º 4
0
void idEditWindow::EnsureCursorVisible()
{
	if( readonly )
	{
		cursorPos = -1;
	}
	else if( maxChars == 1 )
	{
		cursorPos = 0;
	}
	
	if( !dc )
	{
		return;
	}
	
	SetFont();
	if( !wrap )
	{
		int cursorX = 0;
		if( password )
		{
			cursorX = cursorPos * dc->CharWidth( '*', textScale );
		}
		else
		{
			int i = 0;
			while( i < text.Length() && i < cursorPos )
			{
				if( idStr::IsColor( &text[i] ) )
				{
					i += 2;
				}
				else
				{
					cursorX += dc->CharWidth( text[i], textScale );
					i++;
				}
			}
		}
		int maxWidth = GetMaxCharWidth( );
		int left = cursorX - maxWidth;
		int right = ( cursorX - textRect.w ) + maxWidth;
		
		if( paintOffset > left )
		{
			// When we go past the left side, we want the text to jump 6 characters
			paintOffset = left - maxWidth * 6;
		}
		if( paintOffset <  right )
		{
			paintOffset = right;
		}
		if( paintOffset < 0 )
		{
			paintOffset = 0;
		}
		scroller->SetRange( 0.0f, 0.0f, 1.0f );
		
	}
	else
	{
		// Word wrap
		
		breaks.Clear();
		idRectangle rect = textRect;
		rect.w -= sizeBias;
		dc->DrawText( text, textScale, textAlign, colorWhite, rect, true, ( flags & WIN_FOCUS ) ? cursorPos : -1, true, &breaks );
		
		int fit = textRect.h / ( GetMaxCharHeight() + 5 );
		if( fit < breaks.Num() + 1 )
		{
			scroller->SetRange( 0, breaks.Num() + 1 - fit, 1 );
		}
		else
		{
			// The text fits completely in the box
			scroller->SetRange( 0.0f, 0.0f, 1.0f );
		}
		
		if( forceScroll )
		{
			scroller->SetValue( breaks.Num() - fit );
		}
		else if( readonly )
		{
		}
		else
		{
			cursorLine = 0;
			for( int i = 1; i < breaks.Num(); i++ )
			{
				if( cursorPos >= breaks[i] )
				{
					cursorLine = i;
				}
				else
				{
					break;
				}
			}
			int topLine = idMath::Ftoi( scroller->GetValue() );
			if( cursorLine < topLine )
			{
				scroller->SetValue( cursorLine );
			}
			else if( cursorLine >= topLine + fit )
			{
				scroller->SetValue( ( cursorLine - fit ) + 1 );
			}
		}
	}
}