/// <summary> /// Draws a line, either above or below the current text line /// the font is required to get the height of the row /// /// </summary> /// <returns>void</returns> public abstract Boolean DrawLine(float AXPos1, float AXPos2, eLinePosition ALinePosition, eFont AFont);
private float GetFontHeight(eFont AFont) { return GetFontHeight(GetXFont(AFont)); }
/// <summary> /// Reverse Line Feed; decreases the current y position by the height of the given font /// </summary> /// <returns>the new current line /// </returns> public abstract float LineUnFeed(eFont AFont);
/// <summary> /// Draws a line, either above or below the current text line /// the font is required to get the height of the row /// /// </summary> /// <returns>void</returns> public override Boolean DrawLine(float AXPos1, float AXPos2, eLinePosition ALinePosition, eFont AFont) { if (ALinePosition == eLinePosition.eAbove) { // to deal with things already printed in the beginning of the line (e.g. descr) InsertLineForMarkingLine(CurrentYPos); } else if (ALinePosition == eLinePosition.eBelow) { CurrentYPos = CurrentYPos + 1; } if (AXPos1 != 0) { // lines above/below columns should not touch AXPos1 = AXPos1 + 1; AXPos2 = AXPos2 - 1; } if (PrintingMode == ePrintingMode.eDoPrint) { PrintString(new String('-', Convert.ToInt32(AXPos2 - AXPos1 + 1)), eFont.eDefaultFont, Convert.ToInt32(AXPos1)); } CurrentYPos = CurrentYPos + 1; return true; }
/// <summary> /// prints into the current line, aligned x position /// /// </summary> public override Boolean PrintString(String ATxt, eFont AFont, eAlignment AAlign) { RectangleF rect = CalculatePrintStringRectangle(FLeftMargin, CurrentYPos, FWidth, AFont); if (PrintingMode == ePrintingMode.eDoPrint) { ATxt = GetFittedText(ATxt, AFont, rect.Width); FXGraphics.DrawString(ATxt, GetXFont(AFont), Brushes.Black, rect, GetXStringFormat(AAlign)); } return (ATxt != null) && (ATxt.Length != 0); }
/// <summary> /// prints into the current line, absolute x position with width and alignment /// </summary> /// <returns>true if something was printed /// </returns> public override bool PrintString(String ATxt, eFont AFont, float AXPos, float AWidth, eAlignment AAlign) { String ToPrint; System.Int32 XPos; if ((ATxt == null) || (ATxt.Length == 0)) { return false; } ToPrint = GetFittedText(ATxt, AFont, AWidth); // eDefault XPos = Convert.ToInt32(AXPos); switch (AAlign) { case eAlignment.eCenter: XPos = Convert.ToInt32(AXPos) + (Convert.ToInt32(AWidth) - ToPrint.Length) / 2; break; case eAlignment.eLeft: XPos = Convert.ToInt32(AXPos); break; case eAlignment.eRight: if (Convert.ToInt32(AWidth) > ToPrint.Length) { XPos = Convert.ToInt32(AXPos) + Convert.ToInt32(AWidth) - ToPrint.Length; } else { XPos = Convert.ToInt32(AXPos); } break; } if (ToPrint.Length > Convert.ToInt32(AWidth)) { ToPrint = ToPrint.Substring(0, Convert.ToInt32(AWidth)); } Print(XPos, Convert.ToInt32(CurrentYPos), ToPrint); return true; }
/// <summary> /// Cuts a given text so it will not extend the given width. /// </summary> /// <param name="ATxt">The text to cut</param> /// <param name="AFont">The font used</param> /// <param name="AWidth">The available length for the text in cm.</param> /// <returns>The maximum part of the text that will not extend the width.</returns> protected String CutTextToLength(String ATxt, eFont AFont, float AWidth) { String ReturnValue = ""; for (int Counter = 1; Counter <= ATxt.Length; ++Counter) { float length = GetWidthString(ATxt.Substring(0, Counter), AFont); if (length <= AWidth) { ReturnValue = ATxt.Substring(0, Counter); } else { break; } } return ReturnValue; }
/// <summary> /// This function uses the normal DrawString function to print into a given space. /// </summary> /// <returns>whether the text did fit that space or not. /// </returns> public abstract Boolean PrintStringAndFits(String ATxt, eFont AFont, float AXPos, float AWidth, eAlignment AAlign);
/// <summary> /// Return the width of the string, if it was printed in one line, using the given Font /// /// </summary> /// <returns>void</returns> public abstract float GetWidthString(String ATxt, eFont AFont);
/// <summary> /// prints into the current line, absolute x position with width and alignment /// </summary> /// <returns>true if something was printed /// </returns> public abstract bool PrintString(String ATxt, eFont AFont, float AXPos, float AWidth, eAlignment AAlign);
/// <summary> /// prints into the current line, absolute x position with width and alignment /// this method uses FCurrentXPos and FCurrentYPos to be able to continue a paragraph /// uses FCurrentXPos and FCurrentYPos to know where to start to print, and also sets /// valid values in those member variables /// </summary> /// <returns>s bool true if any text was printed</returns> public virtual bool PrintStringWrap(String ATxt, eFont AFont, float AXPos, float AWidth, eAlignment AAlign) { return(false); }
/// <summary> /// prints into the current line, absolute x position /// </summary> /// <returns>true if something was printed /// </returns> public abstract Boolean PrintString(String ATxt, eFont AFont, float AXPos);
/// <summary> /// prints into the current line, aligned x position /// </summary> /// <returns>true if something was printed /// </returns> public abstract Boolean PrintString(String ATxt, eFont AFont, eAlignment AAlign);
/// <summary> /// Set the space that is required by the page footer. /// ValidYPos will consider this value. /// /// </summary> /// <returns>void</returns> public abstract void SetPageFooterSpace(System.Int32 ANumberOfLines, eFont AFont);
/// <summary> /// Line Feed, but not full line; increases the current y position by half the height of the given font /// </summary> /// <returns>the new current line /// </returns> public override float LineSpaceFeed(eFont AFont) { CurrentYPos = CurrentYPos + 1; return CurrentYPos; }
/// <summary> /// Set the space that is required by the page footer. /// ValidYPos will consider this value. /// /// </summary> /// <returns>void</returns> public override void SetPageFooterSpace(System.Int32 ANumberOfLines, eFont AFont) { // just to tell that we accept a page footer; not fully implemented (regarding page breaks etc) if (ANumberOfLines != 0) { FPageFooterSpace = 1; } }
/// <summary> /// Draws a line, either above or below the current text line /// the font is required to get the height of the row /// </summary> /// <param name="AXPos1"></param> /// <param name="AXPos2"></param> /// <param name="ALinePosition"></param> /// <param name="AFont"></param> /// <returns></returns> public override Boolean DrawLine(float AXPos1, float AXPos2, eLinePosition ALinePosition, eFont AFont) { float YPos; YPos = CurrentYPos; if (ALinePosition == eLinePosition.eBelow) { YPos = CurrentYPos + GetFontHeight(AFont); } else if (ALinePosition == eLinePosition.eAbove) { YPos = CurrentYPos; } if (AXPos1 != LeftMargin) { // lines above/below columns should not touch AXPos1 = AXPos1 + Cm(0.3f); } if (PrintingMode == ePrintingMode.eDoPrint) { FXGraphics.DrawLine(FXBlackPen, AXPos1, YPos, AXPos2, YPos); } return(true); }
/// <summary> /// prints into the current line, absolute x position with width and alignment /// this method uses FCurrentXPos and FCurrentYPos to be able to continue a paragraph /// uses FCurrentXPos and FCurrentYPos to know where to start to print, and also sets /// valid values in those member variables /// </summary> /// <returns>s bool true if any text was printed</returns> public override bool PrintStringWrap(String ATxt, eFont AFont, float AXPos, float AWidth, eAlignment AAlign) { while (ATxt.Length > 0) { Int32 firstWordLength; Int32 length = GetTextLengthThatWillFit(ATxt, AFont, AWidth, out firstWordLength); if ((length <= 0) && (CurrentXPos == AXPos) && (firstWordLength > 0)) { // the word is too long, it will never fit; // force to print the first word // todo: this overwrites the text in the next cell; should we break the line inside the word, or not print the overlap? // goal: the problem should be easy to notice by the user... length = firstWordLength; string toPrint = ATxt.Substring(0, length); TLogging.Log("the text \"" + toPrint + "\" does not fit into the assigned space!"); } if (length > 0) { string toPrint = ATxt.Substring(0, length); ATxt = ATxt.Substring(length); float XPos = CalculateXPos(AXPos, AWidth, toPrint, AAlign); //PrintString(toPrint, AFont, FCurrentXPos); Print(Convert.ToInt32(XPos), Convert.ToInt32(CurrentYPos), toPrint); //FCurrentXPos += GetWidthString(toPrint, AFont); if (ATxt.Length > 0) { // there is still more to come, we need a new line LineFeed(); // will use the biggest used font, and reset it } } else if ((ATxt.Length > 0) && (CurrentXPos != AXPos)) { // the first word did not fit the space; needs a new line CurrentXPos = AXPos; LineFeed(); } } return true; }
private float GetFontHeight(eFont AFont) { return(GetFontHeight(GetXFont(AFont))); }
/// <summary> /// This function uses the normal PrintString function to print into a given space. /// </summary> /// <returns>whether the text did fit that space or not. /// </returns> public override Boolean PrintStringAndFits(String ATxt, eFont AFont, float AXPos, float AWidth, eAlignment AAlign) { PrintString(ATxt, AFont, AXPos, AWidth, AAlign); return ATxt.Length <= AWidth; }
/// <summary> /// Line Feed, but not full line; increases the current y position by half the height of the given font /// </summary> /// <returns>the new current line /// </returns> public override float LineSpaceFeed(eFont AFont) { CurrentYPos = CurrentYPos + GetFontHeight(AFont) / 2; return(CurrentYPos); }
/// <summary> /// update the biggest last used font for the next line feed /// </summary> /// <param name="AFont"></param> protected override bool UpdateBiggestLastUsedFont(eFont AFont) { if (base.UpdateBiggestLastUsedFont(AFont)) { FXBiggestLastUsedFont = GetXFont(AFont); return true; } return false; }
/// <summary> /// Reverse Line Feed; decreases the current y position by the height of the given font /// </summary> /// <returns>the new current line /// </returns> public override float LineUnFeed(eFont AFont) { CurrentYPos = CurrentYPos - GetFontHeight(AFont); return(CurrentYPos); }
/// <summary> /// prints into the current line, absolute x position with width and alignment /// </summary> /// <returns>true if something was printed</returns> public override Boolean PrintString(String ATxt, eFont AFont, float AXPos, float AWidth, eAlignment AAlign) { RectangleF rect = CalculatePrintStringRectangle(AXPos, CurrentYPos, AWidth, AFont); if (PrintingMode == ePrintingMode.eDoPrint) { if (FPrinterBehaviour == ePrinterBehaviour.eReport) { ATxt = GetFittedText(ATxt, AFont, rect.Width); } if ((AAlign == eAlignment.eCenter) && Environment.OSVersion.ToString().StartsWith("Unix")) { // it seems on Mono/Unix, the string aligning to the center does not work properly. so we do it manually rect = new RectangleF(rect.Left + (AWidth - GetWidthString(ATxt, AFont)) / 2.0f, rect.Top, rect.Height, rect.Width); FXGraphics.DrawString(ATxt, GetXFont(AFont), Brushes.Black, rect, GetXStringFormat(eAlignment.eLeft)); } else { XStringFormat f = GetXStringFormat(AAlign); f.FormatFlags = XStringFormatFlags.MeasureTrailingSpaces; //TLogging.Log("curr ypos " + CurrentYPos.ToString() + " " + AXPos.ToString() + " " + ATxt + AWidth.ToString()); FXGraphics.DrawString(ATxt, GetXFont(AFont), Brushes.Black, rect, f); } } return (ATxt != null) && (ATxt.Length != 0); }
/// <summary> /// update the biggest last used font for the next line feed /// </summary> /// <param name="AFont"></param> protected virtual bool UpdateBiggestLastUsedFont(eFont AFont) { return(false); }
/// <summary> /// Line Feed, but not full line; increases the current y position by half the height of the given font /// </summary> /// <returns>the new current line /// </returns> public override float LineSpaceFeed(eFont AFont) { CurrentYPos = CurrentYPos + GetFontHeight(AFont) / 2; return CurrentYPos; }
/// <summary> /// prints into the current line, aligned x position /// /// </summary> public override Boolean PrintString(String ATxt, eFont AFont, eAlignment AAlign) { return(false); }
/// <summary> /// prints into the current line, absolute x position /// /// </summary> public override Boolean PrintString(String ATxt, eFont AFont, float AXPos) { return(false); }
/// <summary> /// Line Feed; increases the current y position by one /// </summary> /// <returns>the new current line /// </returns> public override float LineFeed(eFont AFont) { CurrentYPos = CurrentYPos + 1; // check if line is only a marking line; in that case, jump over it string s = GetLine(Convert.ToInt32(CurrentYPos)).Trim(); if (s == new String('-', s.Length)) { CurrentYPos = CurrentYPos + 1; } return CurrentYPos; }
/// <summary> /// prints into the current line, absolute x position with width and alignment /// </summary> /// <returns>true if something was printed</returns> public override Boolean PrintString(String ATxt, eFont AFont, float AXPos, float AWidth, eAlignment AAlign) { return(false); }
/// <summary> /// Reverse Line Feed; decreases the current y position by the height of the given font /// </summary> /// <returns>the new current line /// </returns> public override float LineUnFeed(eFont AFont) { CurrentYPos = CurrentYPos - 1; return CurrentYPos; }
/// <summary> /// word wrap text, return the number of characters that fit the line width; /// if the first word does not fit the space available, wrap the word in itself /// </summary> /// <param name="ATxt"></param> /// <param name="AFont"></param> /// <param name="AWidth"></param> /// <returns>returns the length of the first word; this is needed if even the first word does not fit</returns> protected Int32 GetTextLengthThatWillFit(String ATxt, eFont AFont, float AWidth) { // see also http://www.codeguru.com/vb/gen/vb_misc/printing/article.php/c11233 string buffer = ATxt; string fittingText = ""; char[] whitespace = new char[] { ' ', '\t', '\r', '\n' }; if (FPrinterBehaviour == ePrinterBehaviour.eReport) { // whitespace setting for ePrinterBehaviour.eReport whitespace = new char[] { ' ', '\t', '\r', '\n', '-' }; } string previousWhitespaces = ""; string nextWhitespaces = ""; Int32 result = 0; while (GetWidthString(fittingText, AFont) < AWidth) { result = fittingText.Length; if (buffer.Length == 0) { return(ATxt.Length); } Int32 indexWhitespace = buffer.IndexOfAny(whitespace); if (indexWhitespace > -1) { string nextWord = buffer.Substring(0, indexWhitespace); fittingText += previousWhitespaces + nextWhitespaces + nextWord; nextWhitespaces = ""; // sometimes there are forced whitespaces (eg , already replaced by spaces etc) // consider them as a word previousWhitespaces = buffer[indexWhitespace].ToString(); while (indexWhitespace < buffer.Length - 1 && buffer.Substring(indexWhitespace + 1).IndexOfAny(whitespace) == 0) { indexWhitespace++; nextWhitespaces += buffer[indexWhitespace]; } buffer = buffer.Substring(indexWhitespace + 1); } else // no whitespace left { // store length of result without the rest of the text, because it might not fit; // but include whitespaces already, avoid printing them at start of new line result = (fittingText + previousWhitespaces).Length; fittingText += previousWhitespaces + buffer; previousWhitespaces = ""; buffer = ""; } } if (result > 0) { result += previousWhitespaces.Length; } if (result == 0) { // the first word is already too long for the assigned space // see how many characters would fit buffer = fittingText; fittingText = ""; while (GetWidthString(fittingText, AFont) < AWidth && buffer.Length > 0) { fittingText += buffer[0]; buffer = buffer.Substring(1); } return(fittingText.Length - 1); } return(result); }
/// <summary> /// prints into the current line, aligned x position /// </summary> /// <returns>true if something was printed /// </returns> public override Boolean PrintString(String ATxt, eFont AFont, eAlignment AAlign) { Boolean ReturnValue; Int32 XPos; if ((ATxt == null) || (ATxt.Length == 0)) { return false; } ReturnValue = true; // eDefault XPos = 0; switch (AAlign) { case eAlignment.eCenter: if (FOrientation == eOrientation.ePortrait) { XPos = (NumberOfCharactersPerLinePortrait - ATxt.Length) / 2; } else { XPos = (NumberOfCharactersPerLineLandscape - ATxt.Length) / 2; } break; case eAlignment.eLeft: XPos = 0; break; case eAlignment.eRight: if (FOrientation == eOrientation.ePortrait) { XPos = (Int16)(NumberOfCharactersPerLinePortrait - ATxt.Length); } else { XPos = (Int16)(NumberOfCharactersPerLineLandscape - ATxt.Length); } break; } Print(XPos, Convert.ToInt32(CurrentYPos), ATxt); return ReturnValue; }
/// <summary> /// prints into the current line, absolute x position with width and alignment /// this method uses FCurrentXPos and FCurrentYPos to be able to continue a paragraph /// uses FCurrentXPos and FCurrentYPos to know where to start to print, and also sets /// valid values in those member variables /// </summary> /// <returns>true if any text was printed</returns> public override bool PrintStringWrap(String ATxt, eFont AFont, float AXPos, float AWidth, eAlignment AAlign) { int PreviousLength = -1; while (ATxt.Length > 0) { Int32 length = -1; PreviousLength = ATxt.Length; if (FPrinterBehaviour == ePrinterBehaviour.eFormLetter) { length = GetTextLengthThatWillFit(ATxt, AFont, AXPos + AWidth - CurrentXPos); } else if (FPrinterBehaviour == ePrinterBehaviour.eReport) { length = GetTextLengthThatWillFit(ATxt, AFont, AWidth); } if (FCurrentState.FNoWrap) { length = ATxt.Length; } if (length > 0) { string toPrint = ATxt.Substring(0, length); ATxt = ATxt.Substring(length); if (FPrinterBehaviour == ePrinterBehaviour.eFormLetter) { PrintString(toPrint, AFont, CurrentXPos, AWidth, AAlign); } else if (FPrinterBehaviour == ePrinterBehaviour.eReport) { PrintString(toPrint, AFont, AXPos, AWidth, AAlign); } CurrentXPos += GetWidthString(toPrint, AFont); if (ATxt.Length > 0) { // there is still more to come, we need a new line CurrentXPos = AXPos; LineFeed(); // will use the biggest used font, and reset it } } else if ((ATxt.Length > 0) && (CurrentXPos != AXPos)) { // the first word did not fit the space; needs a new line CurrentXPos = AXPos; LineFeed(); } if (ATxt.Length == PreviousLength) { TLogging.Log("No space for " + ATxt); return(false); } } if (FPrinterBehaviour == ePrinterBehaviour.eReport) { CurrentXPos = 0; } return(true); }
/// <summary> /// prints into the current line, absolute x position /// </summary> /// <returns>true if something was printed /// </returns> public override Boolean PrintString(String ATxt, eFont AFont, float AXPos) { Boolean ReturnValue; ReturnValue = (ATxt.Length != 0); Print(Convert.ToInt32(AXPos), Convert.ToInt32(CurrentYPos), ATxt); return ReturnValue; }
/// <summary> /// This function uses the normal DrawString function to print into a given space. /// It will return whether the text did fit that space or not. /// /// </summary> /// <param name="ATxt"></param> /// <param name="AFont"></param> /// <param name="AXPos"></param> /// <param name="AWidth"></param> /// <param name="AAlign"></param> /// <returns></returns> public override Boolean PrintStringAndFits(String ATxt, eFont AFont, float AXPos, float AWidth, eAlignment AAlign) { PrintString(ATxt, AFont, AXPos, AWidth, AAlign); return(GetWidthString(ATxt, AFont) <= AWidth); }
/// <summary> /// Check if the text will fit into the given width. If yes, the text will be returned. /// If no, the text will be shortened and a "..." will be added to indicate that some text is missing. /// </summary> /// <param name="ATxt">the original text</param> /// <param name="AFont">the font</param> /// <param name="AWidth">the space available for the text in cm</param> /// <returns>The input text. Either unmodified or shortened.</returns> protected String GetFittedText(String ATxt, eFont AFont, float AWidth) { String ReturnValue = ""; if (GetWidthString(ATxt, AFont) <= AWidth) { // The whole text fits into the available space ReturnValue = ATxt; } else { // We have to cut the text float WidthDotDotDot = GetWidthString("...", AFont); float WidthForText = AWidth - WidthDotDotDot; if (WidthForText <= 0.0) { // only space for ... ReturnValue = "..."; } else { ReturnValue = CutTextToLength(ATxt, AFont, WidthForText) + "..."; } } return ReturnValue; }
/// <summary> /// prints into the current line, into the given column /// </summary> /// <param name="ATxt"></param> /// <param name="AFont"></param> /// <returns>Return the width of the string, if it was printed in one line, using the given Font</returns> public override float GetWidthString(String ATxt, eFont AFont) { return(0.0f); }
/// <summary> /// word wrap text, return the number of characters that fit the line width /// </summary> /// <param name="ATxt"></param> /// <param name="AFont"></param> /// <param name="AWidth"></param> /// <param name="firstWordLength">returns the length of the first word; this is needed if even the first word does not fit</param> /// <returns>void</returns> protected Int32 GetTextLengthThatWillFit(String ATxt, eFont AFont, float AWidth, out Int32 firstWordLength) { // see also http://www.codeguru.com/vb/gen/vb_misc/printing/article.php/c11233 string buffer = ATxt; string fittingText = ""; char[] whitespace = new char[] { ' ', '\t', '\r', '\n', '-', ',' }; string previousWhitespace = ""; Int32 result = 0; firstWordLength = 0; while (GetWidthString(fittingText, AFont) < AWidth) { result = fittingText.Length + previousWhitespace.Length; if (buffer.Length == 0) { return result; } Int32 indexWhitespace = buffer.IndexOfAny(whitespace); if (indexWhitespace >= 0) { string nextWord = buffer.Substring(0, indexWhitespace); fittingText += previousWhitespace + nextWord; previousWhitespace = buffer[indexWhitespace].ToString(); buffer = buffer.Substring(indexWhitespace + 1); } else // no whitespace left { fittingText += previousWhitespace + buffer; previousWhitespace = ""; buffer = ""; } if (firstWordLength == 0) { firstWordLength = fittingText.Length + previousWhitespace.Length; } } if (result == 0) { // the first word is to long; Let's split the word for (int Counter = 0; Counter < ATxt.Length; ++Counter) { fittingText = ATxt.Substring(0, Counter); if (GetWidthString(fittingText, AFont) >= AWidth) { result = fittingText.Length - 1; break; } } } return result; }
/// <summary> /// Draws a line, either above or below the current text line /// the font is required to get the height of the row /// </summary> /// <param name="AXPos1"></param> /// <param name="AXPos2"></param> /// <param name="ALinePosition"></param> /// <param name="AFont"></param> /// <returns></returns> public override Boolean DrawLine(float AXPos1, float AXPos2, eLinePosition ALinePosition, eFont AFont) { return(false); }
/// <summary> /// Return the width of the string, if it was printed in one line, using the given Font /// /// </summary> /// <returns>void</returns> public override float GetWidthString(String ATxt, eFont AFont) { return ATxt.Length; }
/// <summary> /// Reverse Line Feed; decreases the current y position by the height of the given font /// </summary> /// <returns>the new current line /// </returns> public override float LineUnFeed(eFont AFont) { return(CurrentYPos); }
private XFont GetXFont(eFont AFont) { XFont ReturnValue = FXDefaultFont; switch (AFont) { case eFont.eDefaultFont: ReturnValue = FXDefaultFont; break; case eFont.eDefaultBoldFont: ReturnValue = FXDefaultBoldFont; break; case eFont.eHeadingFont: ReturnValue = FXHeadingFont; break; case eFont.eSmallPrintFont: ReturnValue = FXSmallPrintFont; break; case eFont.eBarCodeFont: ReturnValue = FXBarCodeFont; break; } Font gFont = GetFont(AFont); string id = ReturnValue.FontFamily.Name + gFont.SizeInPoints.ToString() + gFont.Style.ToString(); if (!FXFontCache.ContainsKey(id)) { XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always); FXFontCache.Add(id, new XFont(ReturnValue.FontFamily.Name, Point(gFont.SizeInPoints /*+XFONTSIZE*/), ReturnValue.Style, options)); } ReturnValue = FXFontCache[id]; return ReturnValue; }
/// <summary> /// Set the space that is required by the page footer. /// ValidYPos will consider this value. /// /// </summary> /// <returns>void</returns> public override void SetPageFooterSpace(System.Int32 ANumberOfLines, eFont AFont) { }
private RectangleF CalculatePrintStringRectangle(float ALeft, float ATop, float AWidth, eFont AFont) { float MyYPos = ATop; if (Environment.OSVersion.ToString().StartsWith("Unix")) { // on Mono/Unix, we have problems with the y position being too high on the page MyYPos += GetFontHeight(AFont); } return new RectangleF(ALeft, MyYPos, AWidth, GetFontHeight(AFont) + 0.2f); }
private XRect CalculatePrintStringRectangle(float ALeft, float ATop, float AWidth, eFont AFont) { float MyYPos = ATop; if (Environment.OSVersion.ToString().StartsWith("Unix")) { // on Mono/Unix, we have problems with the y position being too high on the page MyYPos += GetFontHeight(AFont); } return(new XRect(ALeft, MyYPos, AWidth, GetFontHeight(AFont) + 0.2f)); }
/// <summary> /// prints into the current line, absolute x position /// /// </summary> public override Boolean PrintString(String ATxt, eFont AFont, float AXPos) { if (PrintingMode == ePrintingMode.eDoPrint) { FXGraphics.DrawString(ATxt, GetXFont(AFont), Brushes.Black, AXPos, CurrentYPos); } return (ATxt != null) && (ATxt.Length != 0); }
/// <summary> /// Draws a line, either above or below the current text line /// the font is required to get the height of the row /// </summary> /// <param name="AXPos1"></param> /// <param name="AXPos2"></param> /// <param name="ALinePosition"></param> /// <param name="AFont"></param> /// <returns></returns> public override Boolean DrawLine(float AXPos1, float AXPos2, eLinePosition ALinePosition, eFont AFont) { float YPos; YPos = CurrentYPos; if (ALinePosition == eLinePosition.eBelow) { YPos = CurrentYPos + GetFontHeight(AFont); } else if (ALinePosition == eLinePosition.eAbove) { YPos = CurrentYPos; } if (AXPos1 != LeftMargin) { // lines above/below columns should not touch AXPos1 = AXPos1 + Cm(0.3f); } if (PrintingMode == ePrintingMode.eDoPrint) { FXGraphics.DrawLine(FXBlackPen, AXPos1, YPos, AXPos2, YPos); } return true; }
/// <summary> /// prints into the current line, absolute x position with width and alignment /// this method uses FCurrentXPos and FCurrentYPos to be able to continue a paragraph /// uses FCurrentXPos and FCurrentYPos to know where to start to print, and also sets /// valid values in those member variables /// </summary> /// <returns>s bool true if any text was printed</returns> public virtual bool PrintStringWrap(String ATxt, eFont AFont, float AXPos, float AWidth, eAlignment AAlign) { return false; }
/// <summary> /// prints into the current line, into the given column /// </summary> /// <param name="ATxt"></param> /// <param name="AFont"></param> /// <returns>Return the width of the string, if it was printed in one line, using the given Font</returns> public override float GetWidthString(String ATxt, eFont AFont) { // somehow, on Linux we need to use base.GetWidthString. // on Windows, base.GetWidthString is too long. if (Environment.OSVersion.ToString().StartsWith("Unix")) { // FXGraphics.MeasureString seems to be useless on Mono/Unix. // it returns 0 for single letters, for more letters there is a huge factor of difference to the desired value return base.GetWidthString(ATxt, AFont); } return (float)FXGraphics.MeasureString(ATxt, GetXFont(AFont), XStringFormats.Default).Width; }
/// <summary> /// Reverse Line Feed; decreases the current y position by the height of the given font /// </summary> /// <returns>the new current line /// </returns> public override float LineUnFeed(eFont AFont) { CurrentYPos = CurrentYPos - GetFontHeight(AFont); return CurrentYPos; }
/// <summary> /// Line Feed, but not full line; increases the current y position by half the height of the given font /// </summary> /// <returns>the new current line /// </returns> public abstract float LineSpaceFeed(eFont AFont);