女高中生上课自慰流白浆_金瓶梅全集在线观看_人妻互换免费中文字幕网站_国产玖玖资源站免费_最经典的人与动物故事

| 項(xiàng)目咨詢 |積分體系 | 加入收藏 | 設(shè)為首頁 | RSS
您當(dāng)前的位置:首頁 > 市場 > 百科 > 技術(shù) > 夸父專欄

基于RICHVIEW的EMR開發(fā)文檔十二

時間:2013-10-08 20:45:54  來源:  作者:
更多

 http://blog.sina.com.cn/game7788

   夸父
下面例子實(shí)現(xiàn)ms word風(fēng)格的段落整體對齊功能,當(dāng)在段落頭按下tab鍵時,段落整體向右收縮,當(dāng)按下backspace鍵時,段落整體向左收縮
//定義向右收縮樣式
ChangeFirstIndentConversion(Sender: TCustomRichViewEdit;
  StyleNo, UserData: Integer; AppliedToText: Boolean;
  var NewStyleNo: Integer);
var ParaStyle: TParaInfo;
begin
  ParaStyle := TParaInfo.Create(nil);
  ParaStyle.Assign(Sender.Style.ParaStyles[StyleNo]);
  ParaStyle.FirstIndent := UserData;
  ParaStyle.Standard := False;
  NewStyleNo := Sender.Style.ParaStyles.FindSuchStyle(StyleNo, ParaStyle,
    RVAllParaInfoProperties);
  if NewStyleNo<0 then begin
    Sender.Style.ParaStyles.Add.Assign(ParaStyle);
    NewStyleNo := Sender.Style.ParaStyles.Count-1;
  end;
  ParaStyle.Free;
end;
//定義向左收縮樣式
ChangeLeftIndentConversion(Sender: TCustomRichViewEdit;
  StyleNo, UserData: Integer; AppliedToText: Boolean;
  var NewStyleNo: Integer);
var ParaStyle: TParaInfo;
begin
  ParaStyle := TParaInfo.Create(nil);
  ParaStyle.Assign(Sender.Style.ParaStyles[StyleNo]);
  ParaStyle.LeftIndent := UserData;
  if ParaStyle.LeftIndent=0 then
    ParaStyle.FirstIndent := 0;
  ParaStyle.Standard := False;
  NewStyleNo := Sender.Style.ParaStyles.FindSuchStyle(StyleNo, ParaStyle,
    RVAllParaInfoProperties);
  if NewStyleNo<0 then begin
    Sender.Style.ParaStyles.Add.Assign(ParaStyle);
    NewStyleNo := Sender.Style.ParaStyles.Count-1;
  end;
  ParaStyle.Free;
end;
//實(shí)現(xiàn)過程
function ChangeIndent(rve: TCustomRichViewEdit;
  Step, Max: Integer): Boolean;
var OldParaStyleConversion: TRVStyleConversionEvent;
    FirstIndent, LeftIndent: Integer;
    ListNo, ListLevel, StartFrom: Integer;
    Reset: Boolean; 
begin
  Result := False;
  OldParaStyleConversion := rve.OnParaStyleConversion;
  try
    rve := rve.TopLevelEditor; 
    if rve.SelectionExists then
      exit;
    if (Step>0) and (rve.OffsetInCurItem<=rve.GetOffsBeforeItem(rve.CurItemNo)) and
       (rve.CurItemNo>0) and (rve.GetItemStyle(rve.CurItemNo-1)=rvsListMarker) then begin
       // 改變段落位置
       rve.GetListMarkerInfo(rve.CurItemNo, ListNo, ListLevel, StartFrom, Reset);
       if (ListNo>=0) and (ListNo<rve.Style.ListStyles.Count) and
          (ListLevel+1<rve.Style.ListStyles[ListNo].Levels.Count) then begin
         rve.ChangeListLevels(+1);
         Result := True;
       end;
       exit;
    end;
 
    if (rve.OffsetInCurItem>rve.GetOffsBeforeItem(rve.CurItemNo)) or
      not rve.IsParaStart(rve.CurItemNo) then
      exit; // 不在段落開頭不作處理
    if (rve.OffsetInCurItem>=rve.GetOffsAfterItem(rve.CurItemNo)) and
      ((rve.CurItemNo=rve.ItemCount-1) or rve.IsParaStart(rve.CurItemNo)) then
      exit; // 內(nèi)容為空,不作處理
    FirstIndent := rve.Style.ParaStyles[rve.GetItemPara(rve.CurItemNo)].FirstIndent;
    LeftIndent  := rve.Style.ParaStyles[rve.GetItemPara(rve.CurItemNo)].LeftIndent;
    if Step>0 then begin
      if FirstIndent=0 then begin
        rve.OnParaStyleConversion := ChangeFirstIndentConversion;
        rve.ApplyParaStyleConversion(Step);
        Result := True;
        end
      else begin
        inc(LeftIndent, Step);
        if LeftIndent>Max then
          LeftIndent := Max;
        if LeftIndent>rve.Style.ParaStyles[rve.GetItemPara(rve.CurItemNo)].LeftIndent then begin
          rve.OnParaStyleConversion := ChangeLeftIndentConversion;
          rve.ApplyParaStyleConversion(LeftIndent);
          Result := True;
        end;
      end
      end
    else begin
     if FirstIndent>0 then begin 
        rve.OnParaStyleConversion := ChangeFirstIndentConversion;
        rve.ApplyParaStyleConversion(0);
        Result := True;
        end
      else begin
        inc(LeftIndent, Step);
        if LeftIndent<0 then
          LeftIndent := 0;
        if (LeftIndent
           (FirstIndent<>0) then begin
          rve.OnParaStyleConversion := ChangeLeftIndentConversion;
          rve.ApplyParaStyleConversion(LeftIndent);
          Result := True;
        end;
      end;
    end;
  finally
    rve.OnParaStyleConversion := OldParaStyleConversion;
  end;
end;
//最后在keypress下面處理
var step: Integer;
  begin
  if Key=#9 then begin
    step := 48;
    if GetAsyncKeyState(VK_SHIFT)and$8000<>0 then
      step := -step;
    if ChangeIndent(TCustomRichViewEdit(Sender), step, 480) then
      Key := #0;
  end;
  end;
來頂一下
返回首頁
返回首頁
發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
欄目更新
    欄目熱門