c++开发字处理软件分析一

1.首先整个文档要有一个文档对象负责管理,

然后控件初始化的时候先初始化一下文档对象CurrentEditorControl.InitializeDocument();

            myEMRDoc.RefreshSize();
            myEMRDoc.RefreshLine();

其中 RefreshLine对全部文档重新进行排布和分行,并进行分页处理

目前还不清楚                RefreshPages();
                if (this.myOwnerControl != null)
                {
                    this.myOwnerControl.UpdatePages();
                }

为什么先RefreshPages,后UpdatePages

在UpdatePages中

float rate = (float)(1.0 / this.ClientToViewXRate); 0.32=1/3.12

          System.Drawing.Size size = new System.Drawing.Size(
                (int)(myPages.PaperWidth * rate),
                (int)(myPages.PaperHeight * rate));

得到size是758,1122

            System.Drawing.Size TotalSize = new System.Drawing.Size(
                size.Width + this.intPageSpacing * 2,
                (size.Height + this.intPageSpacing) * myPages.Count + this.intPageSpacing);

TotalSize 是编辑区域控件的大小

            MultiPageTransform trans = (MultiPageTransform)this.myTransform;
            base.intGraphicsUnit = myPages.GraphicsUnit;

            trans.Pages = myPages;
            trans.Refresh(rate, this.intPageSpacing);

            int ClientWidth = this.ClientSize.Width;
            int x = 0;
            if (ClientWidth <= TotalSize.Width)
                x = this.intPageSpacing;
            else
            {
                x = (ClientWidth - TotalSize.Width) / 2 + intPageSpacing;
            }
            trans.OffsetSource(x, 0, false);

//使用trans做一些x y方向上的偏移

            this.RefreshScaleTransform();

            System.Drawing.Rectangle rect = System.Drawing.Rectangle.Empty;

            for (int iCount = 0; iCount < myPages.Count; iCount++)
            {
                rect.X = x;
                rect.Y = (size.Height + this.intPageSpacing) * iCount + this.intPageSpacing;
                rect.Width = size.Width;
                rect.Height = size.Height;
                myPages[iCount].ClientBounds = rect;
            }

//为每一个矩形设置实际显示大小
            this.UpdateCurrentPage();//还不太确定这个的作用

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值