Exemplo n.º 1
0
        private HCDataAnnotate GetDrawItemFirstDataAnnotateAt(int aDrawItemNo, int x, int y)
        {
            HCDataAnnotate Result = null;

            int vStyleNo = GetDrawItemStyle(aDrawItemNo);

            if (vStyleNo > HCStyle.Null)
            {
                Style.ApplyTempStyle(vStyleNo);
            }

            if (DrawItemOfAnnotate(aDrawItemNo, Style.TempCanvas, DrawItems[aDrawItemNo].Rect))
            {
                POINT vPt = new POINT(x, y);
                for (int i = 0; i <= FDrawItemAnnotates.Count - 1; i++)
                {
                    if (HC.PtInRect(FDrawItemAnnotates[i].DrawRect, vPt))
                    {
                        Result = FDrawItemAnnotates[i].DataAnnotate;
                        break;
                    }
                }
            }

            return(Result);
        }
Exemplo n.º 2
0
        private void FormatRange(int aStartDrawItemNo, int aLastItemNo)
        {
            int         vPrioDrawItemNo = -1, vStartItemNo = -1, vStartOffset = -1;
            HCParaStyle vParaStyle = null;
            POINT       vPos       = new POINT();

            FFormatStartDrawItemNo = aStartDrawItemNo;

            // 获取起始DrawItem的上一个序号及格式化开始位置
            if (aStartDrawItemNo > 0)
            {
                vPrioDrawItemNo = aStartDrawItemNo - 1;  // 上一个最后的DrawItem
                vStartItemNo    = DrawItems[aStartDrawItemNo].ItemNo;
                vStartOffset    = DrawItems[aStartDrawItemNo].CharOffs;
                vParaStyle      = Style.ParaStyles[Items[vStartItemNo].ParaNo];
                if (DrawItems[aStartDrawItemNo].LineFirst)
                {
                    vPos.X = vParaStyle.LeftIndentPix;
                    vPos.Y = DrawItems[vPrioDrawItemNo].Rect.Bottom;
                }
                else
                {
                    vPos.X = DrawItems[vPrioDrawItemNo].Rect.Right;
                    vPos.Y = DrawItems[vPrioDrawItemNo].Rect.Top;
                }
            }
            else  // 是第一个
            {
                vPrioDrawItemNo = -1;
                vStartItemNo    = 0;
                vStartOffset    = 1;
                vParaStyle      = Style.ParaStyles[Items[vStartItemNo].ParaNo];
                vPos.X          = vParaStyle.LeftIndentPix;
                vPos.Y          = 0;
            }

            Style.ApplyTempStyle(HCStyle.Null);
            FormatItemToDrawItems(vStartItemNo, vStartOffset, vParaStyle.LeftIndentPix,
                                  FWidth - vParaStyle.RightIndentPix, FWidth, ref vPos, ref vPrioDrawItemNo);

            for (int i = vStartItemNo + 1; i <= aLastItemNo; i++)  // 格式
            {
                if (Items[i].ParaFirst)
                {
                    vParaStyle = Style.ParaStyles[Items[i].ParaNo];
                    vPos.X     = vParaStyle.LeftIndentPix;
                }

                FormatItemToDrawItems(i, 1, vParaStyle.LeftIndentPix,
                                      FWidth - vParaStyle.RightIndentPix, FWidth, ref vPos, ref vPrioDrawItemNo);
            }

            DrawItems.DeleteFormatMark();
        }
Exemplo n.º 3
0
 private void CalcItemFormatHeigh(HCCustomItem AItem)
 {
     if (Style.TempStyleNo != AItem.StyleNo)
     {
         Style.ApplyTempStyle(AItem.StyleNo);
         FLastFormatParaNo = AItem.ParaNo;
         FItemFormatHeight = CalculateLineHeight(Style.TextStyles[AItem.StyleNo], Style.ParaStyles[AItem.ParaNo]);
     }
     else
     if (FLastFormatParaNo != AItem.ParaNo)
     {
         FLastFormatParaNo = AItem.ParaNo;
         FItemFormatHeight = CalculateLineHeight(Style.TextStyles[AItem.StyleNo], Style.ParaStyles[AItem.ParaNo]);
     }
 }
Exemplo n.º 4
0
        /// <summary> 转换指定Item指定Offs格式化为DItem </summary>
        /// <param name="AItemNo">指定的Item</param>
        /// <param name="AOffset">指定的格式化起始位置</param>
        /// <param name="AContentWidth">当前Data格式化宽度</param>
        /// <param name="APageContenBottom">当前页格式化底部位置</param>
        /// <param name="APos">起始位置</param>
        /// <param name="ALastDNo">起始DItemNo前一个值</param>
        /// <param name="vPageBoundary">数据页底部边界</param>
        private void FormatItemToDrawItems(int aItemNo, int aOffset, int aFmtLeft, int aFmtRight, int aContentWidth, ref POINT aPos, ref int aLastDrawItemNo)
        {
            if (!Items[aItemNo].Visible)
            {
                return;
            }

            bool             vParaFirst = false, vLineFirst = false;
            HCCustomRectItem vRectItem = null;
            string           vText     = "";
            RECT             vRect     = new RECT();

            int          vRemainderWidth = 0;
            HCCustomItem vItem           = Items[aItemNo];
            HCParaStyle  vParaStyle      = Style.ParaStyles[vItem.ParaNo];

            if (vItem.ParaFirst && (aOffset == 1))
            {
                vParaFirst = true;
                vLineFirst = true;
                aPos.X    += vParaStyle.FirstIndentPix;
            }
            else  // 非段第1个
            {
                vParaFirst = false;
                vLineFirst = (aPos.X == aFmtLeft) && (DrawItems[aLastDrawItemNo].Width != 0);
            }

            if (!vItem.Visible)  // 不显示的Item
            {
                vRect.Left   = aPos.X;
                vRect.Top    = aPos.Y;
                vRect.Right  = vRect.Left;
                vRect.Bottom = vRect.Top + 5;
                NewDrawItem(aItemNo, aOffset, vItem.Length, vRect, vParaFirst, vLineFirst, ref aLastDrawItemNo);
            }
            else
            if (vItem.StyleNo < HCStyle.Null)
            {
                vRectItem = vItem as HCCustomRectItem;
                DoFormatRectItemToDrawItem(vRectItem, aItemNo, aFmtLeft, aContentWidth, aFmtRight, aOffset,
                                           vParaFirst, vParaStyle, ref aPos, ref vRect, ref vLineFirst, ref aLastDrawItemNo, ref vRemainderWidth);
                // 如果进入表格前是样式1,进入表格里有把Style的全局TempStyleNo改成0,表格后面
                // 是样式0的格式化时,由于此时Data的FItemFormatHeight还是样式1的,应用样式0的
                // StyleNo时和全局的并没有变化,并不能应用修改FItemFormatHeight,所以需要清除一下。
                Style.ApplyTempStyle(HCStyle.Null);
            }
            else  // 文本
            {
                CalcItemFormatHeigh(vItem);
                vRemainderWidth = aFmtRight - aPos.X;

                if (aOffset != 1)
                {
                    vText = vItem.Text.Substring(aOffset - 1, vItem.Length - aOffset + 1);
                }
                else
                {
                    vText = vItem.Text;
                }

                if (vText == "")
                {
                    vRect.Left   = aPos.X;
                    vRect.Top    = aPos.Y;
                    vRect.Right  = vRect.Left;
                    vRect.Bottom = vRect.Top + FItemFormatHeight;  //DefaultCaretHeight;
                    vParaFirst   = true;
                    vLineFirst   = true;
                    NewDrawItem(aItemNo, aOffset, 0, vRect, vParaFirst, vLineFirst, ref aLastDrawItemNo);
                    vParaFirst = false;
                }
                else  // 非空Item
                {
                    int vItemLen = vText.Length;
                    //if (vItemLen > 38347922)
                    //    throw new Exception(HC.HCS_EXCEPTION_STRINGLENGTHLIMIT);
                    int[] vCharWidths = new int[vItemLen];
                    int[] vCharWArr   = null;
                    int   viLen       = vItemLen;
                    if (viLen > FormatTextCut)
                    {
                        vCharWArr = new int[FormatTextCut];
                    }

                    int  vIndex = 0, viBase = 0;
                    SIZE vSize = new SIZE();
                    while (viLen > FormatTextCut)
                    {
                        Style.TempCanvas.GetTextExtentExPoint(vText.Substring(vIndex, FormatTextCut), FormatTextCut, vCharWArr, ref vSize);  // 超过65535数组元素取不到值
                        for (int i = 0; i <= FormatTextCut - 1; i++)
                        {
                            vCharWidths[vIndex + i] = vCharWArr[i] + viBase;
                        }

                        viLen  -= FormatTextCut;
                        vIndex += FormatTextCut;
                        viBase  = vCharWidths[vIndex - 1];
                    }

                    vCharWArr = new int[viLen];
                    Style.TempCanvas.GetTextExtentExPoint(vText.Substring(vIndex, viLen), viLen, vCharWArr, ref vSize);  // 超过65535数组元素取不到值


                    for (int i = 0; i <= viLen - 1; i++)
                    {
                        vCharWidths[vIndex + i] = vCharWArr[i] + viBase;
                    }

                    //SetLength(vCharWArr, 0);
                    DoFormatTextItemToDrawItems(vItem, aOffset, vText, 1, aFmtRight - aPos.X, 0, aItemNo, vItemLen, aFmtLeft, aContentWidth, aFmtRight, vCharWidths,
                                                vParaStyle, ref vParaFirst, ref vLineFirst, ref aPos, ref vRect, ref vRemainderWidth, ref aLastDrawItemNo);
                    //SetLength(vCharWidths, 0);
                }
            }

            // 计算下一个的位置
            if (aItemNo == Items.Count - 1)
            {
                FinishLine(aItemNo, aLastDrawItemNo, vRemainderWidth);
            }
            else  // 不是最后一个,则为下一个Item准备位置
            {
                if (Items[aItemNo + 1].ParaFirst)
                {
                    FinishLine(aItemNo, aLastDrawItemNo, vRemainderWidth);
                    // 偏移到下一行顶端,准备另起一行
                    aPos.X = 0;
                    aPos.Y = DrawItems[aLastDrawItemNo].Rect.Bottom;  // 不使用 vRect.Bottom 因为如果行中间有高的,会修正其bottom
                }
                else  // 下一个不是段起始
                {
                    aPos.X = vRect.Right;  // 下一个的起始坐标
                }
            }
        }