⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fr_desgn.pas

📁 1、开发环境 d6 up2,sqlserver2000, win2000 server 1024*768(笔记本电脑) c/s 2、数据库配置方法
💻 PAS
📖 第 1 页 / 共 5 页
字号:
    else if Cont(t.x + t.dx, t.y, x, y) or Cont(t.x, t.y + t.dy, x, y)then
      Cursor := crSizeNESW
    else if Cont(t.x + t.dx div 2, t.y, x, y) or Cont(t.x + t.dx div 2, t.y + t.dy, x, y) then
      Cursor := crSizeNS
    else if Cont(t.x, t.y + t.dy div 2, x, y) or Cont(t.x + t.dx, t.y + t.dy div 2, x, y) then
      Cursor := crSizeWE
    else
      Cursor := crDefault;
  end;
  // selecting a lot of objects
  if Down and RFlag then
  begin
    DrawFocusRect(OldRect);
    if Cursor = crCross then
      RoundCoord(x, y);
    OldRect := Rect(OldRect.Left, OldRect.Top, x, y);
    DrawFocusRect(OldRect);
    ShowSizes := True;
    if Cursor = crCross then
      FDesigner.PBox1Paint(nil);
    ShowSizes := False;
    Exit;
  end;
  // line drawing
  if Down and (Cursor = crPencil) then
  begin
    kx := x - LastX;
    ky := y - LastY;
    if FAlign and not GridCheck then Exit;
    DrawRectLine(OldRect);
    OldRect := Rect(OldRect.Left, OldRect.Top, OldRect.Right + kx, OldRect.Bottom + ky);
    DrawRectLine(OldRect);
    Inc(LastX, kx);
    Inc(LastY, ky);
    Exit;
  end;
  // check for multiple selected objects - right-bottom corner
  if not Down and (SelNum > 1) and (Mode = mdSelect) then
  begin
    t := Objects[RightBottom];
    if Cont(t.x + t.dx, t.y + t.dy, x, y) then
      Cursor := crSizeNWSE
  end;
  // split checking
  if not Down and (SelNum > 1) and (Mode = mdSelect) then
  begin
    for i := 0 to Objects.Count - 1 do
    begin
      t := Objects[i];
      if (t.Typ <> gtBand) and (t.Typ <> gtLine) and t.Selected then
        if (x >= t.x) and (x <= t.x + t.dx) and (y >= t.y) and (y <= t.y + t.dy) then
        begin
          for j := 0 to Objects.Count - 1 do
          begin
            t1 := Objects[j];
            if (t1.Typ <> gtBand) and (t1 <> t) and t1.Selected then
              if ((t.x = t1.x + t1.dx) and ((x >= t.x) and (x <= t.x + 2))) or
                ((t1.x = t.x + t.dx) and ((x >= t1.x - 2) and (x <= t.x))) then
              begin
                Cursor := crHSplit;
                with SplitInfo do
                begin
                  SplRect := Rect(x, t.y, x, t.y + t.dy);
                  if t.x = t1.x + t1.dx then
                  begin
                    SplX := t.x;
                    View1 := t1;
                    View2 := t;
                  end
                  else
                  begin
                    SplX := t1.x;
                    View1 := t;
                    View2 := t1;
                  end;
                  SplRect.Left := SplX;
                  SplRect.Right := SplX;
                end;
              end;
          end;
        end;
    end;
  end;
  // splitting
  if Down and MRFlag and (Mode = mdSelect) and (Cursor = crHSplit) then
  begin
    kx := x - LastX;
    ky := 0;
    if FAlign and not GridCheck then Exit;
    with SplitInfo do
    begin
      DrawHSplitter(SplRect);
      SplRect := Rect(SplRect.Left + kx, SplRect.Top, SplRect.Right + kx, SplRect.Bottom);
      DrawHSplitter(SplRect);
    end;
    Inc(LastX, kx);
    Exit;
  end;
  // sizing several objects
  if Down and MRFlag and (Mode = mdSelect) and (Cursor <> crDefault) then
  begin
    kx := x - LastX;
    ky := y - LastY;
    if FAlign and not GridCheck then Exit;

    if FDesigner.ShapeMode = smFrame then
      DrawPage(dmShape)
    else
    begin
      hr := CreateRectRgn(0, 0, 0, 0);
      hr1 := CreateRectRgn(0, 0, 0, 0);
    end;
    if not ((OldRect.Right + kx < OldRect.Left) or (OldRect.Bottom + ky < OldRect.Top)) then
      OldRect := Rect(OldRect.Left, OldRect.Top, OldRect.Right + kx, OldRect.Bottom + ky);
    nx := (OldRect.Right - OldRect.Left) / (OldRect1.Right - OldRect1.Left);
    ny := (OldRect.Bottom - OldRect.Top) / (OldRect1.Bottom - OldRect1.Top);
    for i := 0 to Objects.Count - 1 do
    begin
      t := Objects[i];
      if t.Selected then
      begin
        if FDesigner.ShapeMode = smAll then
          AddRgn(hr, t);
        x1 := (t.OriginalRect.Left - LeftTop.x) * nx;
        x2 := t.OriginalRect.Right * nx;
        dx := Round(x1 + x2) - (Round(x1) + Round(x2));
        if DesignerRestrictions * [frdrDontSizeObj] = [] then
          if (t.Restrictions and frrfDontSize) = 0 then
          begin
            t.x := LeftTop.x + Round(x1); t.dx := Round(x2) + dx;
          end;

        y1 := (t.OriginalRect.Top - LeftTop.y) * ny;
        y2 := t.OriginalRect.Bottom * ny;
        dy := Round(y1 + y2) - (Round(y1) + Round(y2));
        if DesignerRestrictions * [frdrDontSizeObj] = [] then
          if (t.Restrictions and frrfDontSize) = 0 then
          begin
            t.y := LeftTop.y + Round(y1); t.dy := Round(y2) + dy;
          end;
        if FDesigner.ShapeMode = smAll then
          AddRgn(hr1, t);
      end;
    end;
    if FDesigner.ShapeMode = smFrame then
      DrawPage(dmShape)
    else
    begin
      Draw(10000, hr);
      Draw(10000, hr1);
    end;
    Inc(LastX, kx);
    Inc(LastY, ky);
    FDesigner.PBox1Paint(nil);
    Exit;
  end;
  // moving
  if Down and (Mode = mdSelect) and (SelNum >= 1) and (Cursor = crDefault) then
  begin
    kx := x - LastX;
    ky := y - LastY;
    if FAlign and not GridCheck then Exit;
    if FirstBandMove and (SelNum = 1) and ((kx <> 0) or (ky <> 0)) and
      not (ssAlt in Shift) then
      if TfrView(Objects[TopSelected]).Typ = gtBand then
      begin
        Bnd := Objects[TopSelected];
        if (Bnd.Restrictions and frrfDontMove) = 0 then
        begin
          for i := 0 to Objects.Count - 1 do
          begin
            t := Objects[i];
            if t.Typ <> gtBand then
              if (t.x >= Bnd.x) and (t.x + t.dx <= Bnd.x + Bnd.dx) and
                 (t.y >= Bnd.y) and (t.y + t.dy <= Bnd.y + Bnd.dy) then
              begin
                t.Selected := True;
                Inc(SelNum);
              end;
          end;
          FDesigner.SelectionChanged;
          GetMultipleSelected;
        end;
      end;
    FirstBandMove := False;
    if FDesigner.ShapeMode = smFrame then
      DrawPage(dmShape)
    else
    begin
      hr := CreateRectRgn(0, 0, 0, 0);
      hr1 := CreateRectRgn(0, 0, 0, 0);
    end;
    cv := false;
    for i := 0 to Objects.Count - 1 do
    begin
      t := Objects[i];
      if not t.Selected then continue;
      if t.ClassName = 'TfrCrossView' then
        cv := True;
      if FDesigner.ShapeMode = smAll then
        AddRgn(hr, t);
      if DesignerRestrictions * [frdrDontMoveObj] = [] then
        if (t.Restrictions and frrfDontMove) = 0 then
        begin
          t.x := t.x + kx;
          t.y := t.y + ky;
        end;
      if FDesigner.ShapeMode = smAll then
        AddRgn(hr1, t);
    end;
    if FDesigner.ShapeMode = smFrame then
      DrawPage(dmShape)
    else
    begin
      CombineRgn(hr, hr, hr1, RGN_OR);
      DeleteObject(hr1);
      Draw(10000, hr);
      if cv then
        Draw(10000, 0);
    end;
    Inc(LastX, kx);
    Inc(LastY, ky);
    FDesigner.PBox1Paint(nil);
  end;
 // resizing
  if Down and (Mode = mdSelect) and (SelNum = 1) and (Cursor <> crDefault) then
  begin
    kx := x - LastX;
    ky := y - LastY;
    if FAlign and not GridCheck then Exit;
    t := Objects[TopSelected];
    if FDesigner.ShapeMode = smFrame then
      DrawPage(dmShape) else
      hr := t.GetClipRgn(rtExtended);
    w := 3;
    if (DesignerRestrictions * [frdrDontSizeObj] = []) and
       ((t.Restrictions and frrfDontSize) = 0) then
    begin
      if Cursor = crSizeNWSE then
        if (CT <> ct2) and ((CT = ct1) or Cont(t.x, t.y, LastX, LastY)) then
        begin
          t.x := t.x + kx;
          t.dx := t.dx - kx;
          t.y := t.y + ky;
          t.dy := t.dy - ky;
          if CheckNegative(t) then
            CT := ct2 else
            CT := ct1;
        end
        else
        begin
          t.dx := t.dx + kx;
          t.dy := t.dy + ky;
          if CheckNegative(t) then
            CT := ct1 else
            CT := ct2;
        end;
      if Cursor = crSizeNESW then
        if (CT <> ct4) and ((CT = ct3) or Cont(t.x + t.dx, t.y, LastX, LastY)) then
        begin
          t.y := t.y + ky;
          t.dx := t.dx + kx;
          t.dy := t.dy - ky;
          if CheckNegative(t) then
            CT := ct4 else
            CT := ct3;
        end
        else
        begin
          t.x := t.x + kx;
          t.dx := t.dx - kx;
          t.dy := t.dy + ky;
          if CheckNegative(t) then
            CT := ct3 else
            CT := ct4;
        end;
      if Cursor = crSizeWE then
        if (CT <> ct6) and ((CT = ct5) or Cont(t.x, t.y + t.dy div 2, LastX, LastY)) then
        begin
          t.x := t.x + kx;
          t.dx := t.dx - kx;
          if CheckNegative(t) then
            CT := ct6 else
            CT := ct5;
        end
        else
        begin
          t.dx := t.dx + kx;
          if CheckNegative(t) then
            CT := ct5 else
            CT := ct6;
        end;
      if Cursor = crSizeNS then
        if (CT <> ct8) and ((CT = ct7) or Cont(t.x + t.dx div 2, t.y, LastX, LastY)) then
        begin
          t.y := t.y + ky;
          t.dy := t.dy - ky;
          if CheckNegative(t) then
            CT := ct8 else
            CT := ct7;
        end
        else
        begin
          t.dy := t.dy + ky;
          if CheckNegative(t) then
            CT := ct7 else
            CT := ct8;
        end;
    end;
    if FDesigner.ShapeMode = smFrame then
      DrawPage(dmShape)
    else
    begin
      CombineRgn(hr, hr, t.GetClipRgn(rtExtended), RGN_OR);
      Draw(10000, hr);
    end;
    Inc(LastX, kx);
    Inc(LastY, ky);
    FDesigner.PBox1Paint(nil);
  end;

  if shift = [ssLeft] then
  begin
    ii := 0;
    with TScrollBox(Parent) do
    begin
      if x > (ClientRect.Right + HorzScrollBar.Position) then
      begin
        ii := x - (ClientRect.Right + HorzScrollBar.Position);
        HorzScrollBar.Position := HorzScrollBar.Position + ii;
      end;
      if x < HorzScrollBar.Position then
      begin
        ii := HorzScrollBar.Position - x;
        HorzScrollBar.Position := HorzScrollBar.Position - ii;
      end;
      if y > (ClientRect.Bottom + VertScrollBar.Position) then
      begin
        ii := y - (ClientRect.Bottom + VertScrollBar.Position);
        VertScrollBar.Position := VertScrollBar.Position + ii;
      end;
      if y < VertScrollBar.Position then
      begin
        ii := VertScrollBar.Position - y;
        VertScrollBar.Position := VertScrollBar.Position - ii;
      end;
    end;
    if ii <> 0 then
    begin
      self.Refresh;
      DrawFocusRect(OldRect);
    end;
  end;
end;

procedure TfrDesignerPage.DClick(Sender: TObject);
begin
  Down := False;
  if SelNum = 0 then
    if FDesigner.PageType = ptReport then
    begin
      FDesigner.PgB3Click(nil);
      DFlag := True;
    end
    else
    begin
      DFlag := True;
      FDesigner.Page.ScriptEditor(nil);
    end
  else if SelNum = 1 then
  begin
    DFlag := True;
    if WasCtrl then
      FDesigner.ShowMemoEditor(nil) else
      FDesigner.ShowEditor;
  end
  else Exit;
end;

procedure TfrDesignerPage.CMMouseLeave(var Message: TMessage);
begin
  if ((Mode = mdInsert) and not Down) or FDrag then
  begin
    if FDesigner.PageType = ptReport then
      DrawFocusRect(OldRect);
    OffsetRect(OldRect, -10000, -10000);
  end;
end;

procedure TfrDesignerPage.DoDragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
var
  kx, ky: Integer;
begin
  Accept := (Source is TListBox) and
            (DesignerRestrictions * [frdrDontCreateObj] = []) and
            (FDesigner.PageType = ptReport);
  if not Accept then Exit;
  if not FDrag then
  begin
    FDrag := True;
    FDesigner.GetDefaultSize(kx, ky);
    OldRect := Rect(x - 4, y - 4, x + kx - 4, y + ky - 4);
  end
  else
    DrawFocusRect(OldRect);
  RoundCoord(x, y);
  OffsetRect(OldRect, x - OldRect.Left - 4, y - OldRect.Top - 4);
  DrawFocusRect(OldRect);
end;

procedure TfrDesignerPage.DoDragDrop(Sender, Source: TObject; X, Y: Integer);
var
  t: TfrView;
begin
  DrawPage(dmSelection);
// emulating object insertion
  FDesigner.OB2.Down := True;
  Cursor := crCross;
  MUp(nil, mbLeft, [], 0, 0);
  t := Objects[TopSelected];
  t.Memo.Text := '[' + frFieldsDialog.DBField + ']';
  DrawSelection(t);
  t.Draw(Canvas);
  DrawSelection(t);
end;


{-----------------------------------------------------------------------------}
procedure BDown(SB: TfrSpeedButton);
begin
  SB.Down := True;
end;

procedure BUp(SB: TfrSpeedButton);
begin
  SB.Down := False;
end;

procedure TfrDesignerForm.Localize;
begin
  FCaption :=         frLoadStr(frRes + 080);
  Panel1.Caption :=   frLoadStr(frRes + 081);
  Panel2.Caption :=   frLoadStr(frRes + 082);
  Panel3.Caption :=   frLoadStr(frRes + 083);
  Panel4.Caption :=   frLoadStr(frRes + 084);
  Panel5.Caption :=   frLoadStr(frRes + 085);
  Panel6.Caption :=   frLoadStr(frRes + 086);
  FileBtn1.Hint :=    frLoadStr(frRes + 087);
  FileBtn2.Hint :=    frLoadStr(frRes + 088);
  FileBtn3.Hint :=    frLoadStr(frRes + 089);
  FileBtn4.Hint :=    frLoadStr(frRes + 090);
  CutB.Hint :=        frLoadStr(frRes + 091);
  CopyB.Hint :=       frLoadStr(frRes + 092);
  PstB.Hint :=        frLoadStr(frRe

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -