示例#1
0
        /// <summary>
        /// print the footer of the page;
        /// can contain eg. long caption lines that did not fit at top of the columns
        /// </summary>
        public override void PrintPageFooter()
        {
            System.Int32 columnNr;
            String       Caption;
            float        StringWidth;
            float        CurrentXPos;
            Int32        oldCurrentSubReport;

            if (FPrinter.PageFooterSpace == 0)
            {
                // this printer does not support page footers
                return;
            }

            FPrinter.LineFeedToPageFooter();
            FPrinter.DrawLine(FPrinter.LeftMargin, FPrinter.Width, eLinePosition.eAbove, eFont.eDefaultBoldFont);
            FPrinter.LineSpaceFeed(eFont.eSmallPrintFont);

            /*
             * TLogging.Log('TopMargin in cm: ' + Convert.ToString(TopMargin* 2.54));
             * TLogging.Log('BottomMargin in cm: ' + Convert.ToString(BottomMargin* 2.54));
             * TLogging.Log('Height in cm: ' + Convert.ToString(Height* 2.54));
             * TLogging.Log('Footerspace in cm: ' + Convert.ToString(FPageFooterSpace));
             * TLogging.Log('smallprintheight in cm: ' + Convert.ToString(SmallPrintFont.GetHeight(ev.Graphics)));
             * TLogging.Log('defaultheight in cm: ' + Convert.ToString(DefaultFont.GetHeight(ev.Graphics)));
             */
            oldCurrentSubReport = FParameters.Get("CurrentSubReport").ToInt();
            FParameters.Add("CurrentSubReport", -1);
            CurrentXPos = FPrinter.LeftMargin;

            for (columnNr = 0; columnNr <= FNumberColumns - 1; columnNr += 1)
            {
                if (FParameters.Exists("LongCaption", columnNr))
                {
                    Caption     = Get("LongCaption", columnNr);
                    StringWidth = FPrinter.GetWidthString(Caption, eFont.eSmallPrintFont);

                    if (FPrinter.ValidXPos(CurrentXPos + StringWidth))
                    {
                        // can print in same line
                        FPrinter.PrintString(Caption, eFont.eSmallPrintFont, CurrentXPos);
                    }
                    else
                    {
                        FPrinter.LineFeed(eFont.eSmallPrintFont);
                        CurrentXPos = FPrinter.LeftMargin;
                        FPrinter.PrintString(Caption, eFont.eSmallPrintFont, CurrentXPos);
                    }

                    CurrentXPos = CurrentXPos + StringWidth + FPrinter.GetWidthString("a", eFont.eSmallPrintFont) * 7;
                }
            }

            FParameters.Add("CurrentSubReport", oldCurrentSubReport);
        }
示例#2
0
        /// <summary>
        /// prints the captions of the columns;
        /// prepare the footer lines for long captions;
        /// is called by PrintPageHeader
        ///
        /// </summary>
        /// <returns>void</returns>
        protected override void PrintColumnCaptions()
        {
            int    columnNr;
            String Caption;

            System.Int32 NumberFooterLines;
            System.Int32 NumberFootNotes;
            float        YPosStartCaptions;
            float        LowestYPosCaptions;
            float        FooterXPos;
            bool         NeedCaptionInFooter;
            String       CaptionParameter;
            float        StringWidth;
            Int32        oldCurrentSubReport;
            eAlignment   CaptionAlignment;

            oldCurrentSubReport = FParameters.Get("CurrentSubReport").ToInt();
            FParameters.Add("CurrentSubReport", -1);
            FNumberColumns = -1;

            for (columnNr = 0; columnNr <= Convert.ToInt32(Get("MaxDisplayColumns")) - 1; columnNr += 1)
            {
                if (Get("param_calculation", columnNr) != "")
                {
                    FNumberColumns = columnNr + 1;
                }
            }

            YPosStartCaptions  = FPrinter.CurrentYPos;
            LowestYPosCaptions = FPrinter.CurrentYPos;
            NumberFooterLines  = 0;
            NumberFootNotes    = 0;
            FooterXPos         = FPrinter.LeftMargin;

            for (columnNr = 0; columnNr <= FNumberColumns - 1; columnNr += 1)
            {
                // go back to top of the caption rows.
                FPrinter.CurrentYPos = YPosStartCaptions;
                NeedCaptionInFooter  = false;

                // should we use the normal or the short version of the caption?
                // if a short version exists, it will be used, and the long version will be printed in the footer of the page
                CaptionParameter = "ColumnCaption";

                if (FParameters.Exists("ColumnShortCaption", columnNr))
                {
                    CaptionParameter    = "ColumnShortCaption";
                    NeedCaptionInFooter = true;
                }

                CaptionAlignment = eAlignment.eCenter;

                if (Get("ColumnAlign", columnNr) == "left")
                {
                    CaptionAlignment = eAlignment.eLeft;
                }

                Caption = Get(CaptionParameter, columnNr);

                if ((!FPrinter.PrintStringAndFits(Caption, eFont.eDefaultBoldFont, GetPosition(columnNr, -1, 0),
                                                  GetWidth(columnNr, -1, 0), CaptionAlignment)))
                {
                    // (Columns[columnNr] as RectangleF).Left
                    // (Columns[columnNr] as RectangleF).Width
                    // if the text is still too long, add a line to the footer
                    NeedCaptionInFooter = true;
                }

                FPrinter.LineFeed(eFont.eDefaultFont);
                Caption = Get(CaptionParameter + '2', columnNr);

                if (Caption.Length > 0)
                {
                    if ((!FPrinter.PrintStringAndFits(Caption, eFont.eDefaultFont,
                                                      GetPosition(columnNr, -1, 0), GetWidth(columnNr, -1, 0), eAlignment.eCenter)))
                    {
                        // (Columns[columnNr] as RectangleF).Left
                        // (Columns[columnNr] as RectangleF).Width
                        // if the text is still too long, add a line to the footer
                        NeedCaptionInFooter = true;
                    }

                    FPrinter.LineFeed(eFont.eDefaultFont);
                }

                // 3rd header line
                Caption = Get(CaptionParameter + "3", columnNr);

                if (Caption.Length > 0)
                {
                    if ((!FPrinter.PrintStringAndFits(Caption, eFont.eDefaultFont,
                                                      GetPosition(columnNr, -1, 0),
                                                      GetWidth(columnNr, -1, 0),
                                                      eAlignment.eCenter)))
                    {
                        // (Columns[columnNr] as RectangleF).Left
                        // (Columns[columnNr] as RectangleF).Width
                        // if the text is still too long, add a line to the footer
                        NeedCaptionInFooter = true;
                    }

                    FPrinter.LineFeed(eFont.eDefaultFont);
                }

                if (NeedCaptionInFooter)
                {
                    NumberFootNotes = NumberFootNotes + 1;

                    // save current lowest point
                    if (FPrinter.CurrentYPos > LowestYPosCaptions)
                    {
                        LowestYPosCaptions = FPrinter.CurrentYPos;
                    }

                    // go back into the first line of the caption
                    FPrinter.CurrentYPos = YPosStartCaptions;
                    FPrinter.PrintString("(" + NumberFootNotes.ToString() + ")",
                                         eFont.eSmallPrintFont,
                                         GetPosition(columnNr, -1, 0),
                                         GetWidth(columnNr, -1, 0),
                                         eAlignment.eRight);

                    // (Columns[columnNr] as RectangleF).Left
                    // (Columns[columnNr] as RectangleF).Width
                    Caption = Convert.ToString(NumberFootNotes) + ": " +
                              Get("ColumnCaption", columnNr) + " " +
                              Get("ColumnCaption2", columnNr) + " " +
                              Get("ColumnCaption3", columnNr);
                    FParameters.Add("LongCaption", new TVariant(Caption), columnNr);

                    // simulate the printing of the footer, to know how many rows are needed in the footer
                    StringWidth = FPrinter.GetWidthString(Caption, eFont.eSmallPrintFont);

                    if (!FPrinter.ValidXPos(FooterXPos + StringWidth))
                    {
                        FooterXPos        = FPrinter.LeftMargin;
                        NumberFooterLines = NumberFooterLines + 1;
                    }

                    FooterXPos = FooterXPos + StringWidth + FPrinter.GetWidthString("a", eFont.eSmallPrintFont) * 7;
                }

                // store the highest caption
                if (FPrinter.CurrentYPos > LowestYPosCaptions)
                {
                    LowestYPosCaptions = FPrinter.CurrentYPos;
                }
            }

            // feed forward to the lowest position after the captions
            FPrinter.CurrentYPos = LowestYPosCaptions;

            // if the line has not just begun, then add one more line
            if (FooterXPos != FPrinter.LeftMargin)
            {
                NumberFooterLines = NumberFooterLines + 1;
            }

            FPrinter.SetPageFooterSpace(NumberFooterLines, eFont.eSmallPrintFont);
            FParameters.Add("CurrentSubReport", oldCurrentSubReport);
        }